DECLARE @sql NVARCHAR(1000)
DECLARE @j INT
DECLARE @t1 INT
SET @sql='select @i=count(1),@t=sum(id) from L_user'
EXEC sp_executesql @sql, N'@i int output,@t int output',@i = @j OUTPUT,@t = @t1 OUTPUT --带两个返回值
SELECT @j,@t1
输出:
33,21
DECLARE @sql NVARCHAR(1000)
DECLARE @j INT
DECLARE @t1 INT
SET @sql='select @i=count(1),@t=sum(id) from L_user'
EXEC sp_executesql @sql, N'@i int ,@t int output',@i = @j ,@t = @t1 OUTPUT --带两个返回值
SELECT @j,@t1
输出:
null,21 (@j没有output)
详细请看: