sql exec sp_executesql执行动态语句

SET @VarSql = ‘SELECT TOP 1 @Count=W_Count‘+@i+‘,@Amount=W_Amount‘+@i+‘,@AddCount=W_AddCount‘+@i+‘,@AddAmount=W_AddAmount‘+@i+‘,@DecCount=W_DecCount‘+@i+‘ from #欠费 where P_PriceID=@P_PriceID‘

exec sp_executesql @VarSql,N‘@P_PriceID NUMERIC(18,0),@Count DECIMAL(18,2) output,@Amount DECIMAL(18,2) output,@AddCount DECIMAL(18,2) output,@AddAmount DECIMAL(18,2) output,@DecCount DECIMAL(18,2) output‘,@P_PriceID,@Count output,@Amount output,@AddCount output,@AddAmount output,@DecCount output

sql exec sp_executesql执行动态语句

上一篇:MySQL 到 ClickHouse 的高速公路


下一篇:支持批量执行的mysql存储过程