U Url Onz Dec 2, 2003 #1 Is there any T-SQL that will find an empty table or which tables have records?
V Vadim Rapp Dec 2, 2003 #2 UO> Is there any T-SQL that will find an empty table UO> or which tables have records? along these lines: declare c cursor for select name from sysobjects where xtype='U' open c Fetchnext: fetch next C into @tname <if eof then leave> declare @sql nvarchar(50) set @sql='select @i=count(*) from ' + @tname declare @i int exec sp_executesql @sql,N'@i int output',@i output if @i=0 then @tname is empty goto fetchnext Vadim
UO> Is there any T-SQL that will find an empty table UO> or which tables have records? along these lines: declare c cursor for select name from sysobjects where xtype='U' open c Fetchnext: fetch next C into @tname <if eof then leave> declare @sql nvarchar(50) set @sql='select @i=count(*) from ' + @tname declare @i int exec sp_executesql @sql,N'@i int output',@i output if @i=0 then @tname is empty goto fetchnext Vadim