SQL server 2008 - SET QUOTED_IDENTIFIER OFF

时间:2014-05-13 04:19:17

标签: sql-server-2008

有人可以帮我解决下面的脚本吗?我知道如何返回计算值500 * @ point_rate。我收到以下错误消息

  

Msg 235,Level 16,State 0,Line 18
  无法将char值转换为money。 char值的语法不正确。

脚本:

DECLARE @SCRIPT VARCHAR(4000)
DECLARE @POINT_RATE MONEY
SET @POINT_RATE = 0.05          


SET QUOTED_IDENTIFIER OFF

SET @SCRIPT = "SELECT 500*'"+ @POINT_RATE + "'"

PRINT @SCRIPT

1 个答案:

答案 0 :(得分:0)

您需要CASTVARCHAR

这样的东西
DECLARE @SCRIPT VARCHAR(4000)
DECLARE @POINT_RATE MONEY
SET @POINT_RATE = 0.05          


SET QUOTED_IDENTIFIER OFF

SET @SCRIPT = "SELECT 500*"+ CAST(@POINT_RATE AS VARCHAR(10))

PRINT @SCRIPT