mssql中如何将参数传递到括号内

我的数据库中一些表有数据,一些表无数据,我需要把有数据的表名称提取出来,但是不删除(仅仅提取表名称而已)。写了以下这段话,求指正。没分悬赏了,感谢好心人。
declare
@id int,
@maxid int,
@name char(100),
@sql nvarchar(max);

set @id=1;
select @maxid =max(id) from tablename;

while @id<=@maxid

begin
select @name=name from tablename where id=@id
if not exists(select top 1 1 from @name)
delete from tablename where id=@id;

set @id=@id+1;
end;
go

select name from tablename

这种情总用SCHEMA处理

select a.TABLE_NAME,a.TABLE_ROWS from information_schema.TABLES a where a.TABLE_SCHEMA = 'higo' and a.table_rows > 0;

资料
20.23. The INFORMATION_SCHEMA TABLES Table

select a.name from sysobjects as a inner join sysindexes as b on a.id=b.id where a.type='U' and b.rows>0 and b.indid<2

不知道这样可不可以

参考 Query to list number of records in each table in a database

上面的答案有帮助吗?如果还有问题,请提出来,如果对答案满意,请顶一下,并标记为采纳答案,谢谢!