存储过程中执行带输出参数的动态SQL
--存储过程中执行带输出参数的动态SQL
declare @sql nvarchar(max)
declare @tableName varchar(200)
declare @id int
set @tableName='tableA'
set @sql = 'select @id=id from ' + @tableName
exec sp_executesql @sql, N'@id int output', @id output
select @id