多参数sp_executesql
declare @sql1 nvarchar(2500)
set @sql1='
select top 1 @test1=column1,@test2=column1 from table1'
exec sp_executesql @sql1,N'@income decimal(18,4) out,@outlay decimal(18,4) out',@test1 out,@test2 out
需要注意的是: set @sql1='
select top 1 @test1=column1,@test2=column1 from table1'
exec sp_executesql @sql1,N'@income decimal(18,4) out,@outlay decimal(18,4) out',@test1 out,@test2 out
1. sp_executesql的头两个参数必须是nvarchar类型,如@sql1和N'...'
2. 多参时sp_executesql第二个参数的格式