存储过程中执行@sql 变量语句时,需要返回值需要用到sq_executesql

exec sp_executesql @sqlstr,N'@output int output',@output output

而且需要执行的@sql变量必须是nvarchar数据类型