如何在SQL中打印字符串 [英] How to print a string in SQL
本文介绍了如何在SQL中打印字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
声明 @ Que nvarchar (max), @ MonthNm nvarchar ( 50 ), @ UpdateMonth decimal ( 18 , 2 )
set @ MonthNm = ' July'
set @ UpdateMonth = 1500
set @Que ='update INCENTIVE.dbo.Direct_Summary_Policies set'+ @ MonthNm +'='+ @ UpdateMonth
print @Que
it giver error:
将nvarchar转换为数据类型numeric的算术溢出错误。
如何解决?
解决方案
尝试:
set @ Que = ' update INCENTIVE.dbo.Direct_Summary_Policies set' + @ MonthNm + ' =' + CONVERT( NVARCHAR ( 10 ), @ UpdateMonth )
您好,
不清楚,你想说什么。但看到你的错误......
试试这个..
set @ Que = ' < span class =code-string> UPDATE INCENTIVE.dbo.Direct_Summary_Policies SET' + @ MonthNm + ' =' + CONVERT ( VARCHAR , @ UpdateMonth )+ ' ''
打印(@Que)
希望这会有所帮助你
declare @Que nvarchar(max),@MonthNm nvarchar(50),@UpdateMonth decimal(18,2)
set @MonthNm='July'
set @UpdateMonth=1500
set @Que ='update INCENTIVE.dbo.Direct_Summary_Policies set '+@MonthNm+'='+@UpdateMonth
print @Que
it giver error:
Arithmetic overflow error converting nvarchar to data type numeric.
How to resolve ?
解决方案
Try:
set @Que ='update INCENTIVE.dbo.Direct_Summary_Policies set '+@MonthNm+'='+CONVERT(NVARCHAR(10),@UpdateMonth)
Hi,
Not clear about, what exactly you want to say. But seeing your error...
Try this one..
set @Que ='UPDATE INCENTIVE.dbo.Direct_Summary_Policies SET ' + @MonthNm + ' = ' + CONVERT(VARCHAR,@UpdateMonth) + ''' Print (@Que)
Hope this will help you.
这篇关于如何在SQL中打印字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文