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

posted @ 2021-07-08 13:06  世人皆萌  阅读(135)  评论(0编辑  收藏  举报