use 库名godeclare @tablename nvarchar(100)declare @sql nvarchar(2000)declare @count intdeclare @a intdeclare cur_c cursor forselect name from sysobjects where xtype='U' and status>=0open cur_cfetch next from cur_c into @tablenamewhile @@fetch_status = 0begin set @sql='select @a=count(*) from '+@tablename+'' exec sp_executesql @sql,N'@a int output',@count output if @count=0 print @tablename fetch next from cur_c into @tablenameendclose cur_cdeallocate cur_c