首页 > 代码库 > sql数据库表名做参数

sql数据库表名做参数

declare @tablename nvarchar(50)
declare @count int
set @tablename = ‘SplitzRank‘
declare @sqlstr nvarchar(512)
set @sqlstr = ‘select @count=count(*) from ‘+@tablename
select @sqlstr
exec sp_executesql @sqlstr,N‘@count int output‘,@count output
select @count