create proc get_all_null_table as begin declare @tb table(name varchar(255))declare @tbname varchar(255) declare @m int declare @sql Nvarchar(300) declare cr cursor for select name from sysobjects where type='u' set nocount on open cr fetch next from cr into @tbname while @@fetch_status =0 begin set @sql='select @m=count(*) from '+@tbname exec sp_executesql @sql,N'@m int output',@m output if @m=0 begin insert into @tb values(@tbname) end fetch next from cr into @tbname end close cr deallocate cr set nocount off select * from @tb end
sp_msforeachtable 'select count(*),''?'' from ? having count(*) = 0 '
select distinct a.name from sysindexes b,sysobjects a where a.type='u' and a.id=b.id and b.rowcnt=0 and b.indid < 2
sp_msforeachtable 'select ''?'' from ? having count(*) = 0 '
as
begin
declare @tb table(name varchar(255))declare @tbname varchar(255)
declare @m int
declare @sql Nvarchar(300)
declare cr cursor for select name from sysobjects where type='u'
set nocount on
open cr
fetch next from cr into @tbname
while @@fetch_status =0
begin
set @sql='select @m=count(*) from '+@tbname
exec sp_executesql @sql,N'@m int output',@m output
if @m=0
begin
insert into @tb values(@tbname)
end
fetch next from cr into @tbname
end
close cr
deallocate cr
set nocount off
select * from @tb
end
from sysindexes b,sysobjects a
where a.type='u' and a.id=b.id and b.rowcnt=0 and b.indid < 2