当前位置:Gxlcms > 数据库问题 > 动态的调用输出查询语句中的值 execute sp_executesql

动态的调用输出查询语句中的值 execute sp_executesql

时间:2021-07-01 10:21:17 帮助过:29人阅读

sql语句,参数,变量=@count output 例:

declare @exec_sqlCount nvarchar(1000)

declare @count int

set @exec_sqlCount= ‘select @count=sum(t.a) from t ‘

declare @scon nvarchar(100)=‘@count int output‘ --定义一个输出参数
execute sp_executesql @exec_sqlCount,@scon,@count=@count output --执行

--很多时候查询的时候不能将查到的值带出,所已可用该方法。。

动态的调用输出查询语句中的值 execute sp_executesql

标签:

人气教程排行