sp_executesql可以有输出参数
declare @ta Nvarchar(10)
declare @cou int
declare @sql Nvarchar(200)
declare @para Nvarchar(200)
set @ta = N''[#tmp]''
set @sql=N''select @count=count(*) from ''+@ta
set @para= N''@count int output''
exec sp_executesql @sql,@para,@count=@cou output
print @cou