SQL Casting错误(更新后的帖子)

时间:2014-06-17 16:38:04

标签: sql sql-server

新问题
我研究了在SQL中使用强制转换功能的网页。我遵循与示例相同的格式,但仍然无法正常工作。有什么建议?它给出了与下面相同的错误消息。

这就是我想要做的事情:

update dbo.TableName
set cast(columnName1 as decimal (9,1)) = 10,
    cast(columnName2 as decimal (9,1)) = 11
where ... etc

上一篇文章:

When compiling my code, I get this error message: "Microsoft.Rules.Data: Data loss might occur when casting from Integer to Decimal(9,1)." So I put a basic cast in there (see below) and for some reason it doesn't work. Any suggestions? I get the following error messages:

       -- 1). SQL 80001: Incorrect syntax near'0'. Expecting '(', or SELECT.
       -- 2). SQL 80001: Incorrect syntax near '9'. Expecting '(', or SELECT.
       -- 3). SQL 80001: Incorrect syntax near ';'. Expecting CONVERSION.
       -- 4). SQL 46010: Incorrect syntax near 0.

    exec dbo.Name
         @variable1,
         cast((0) as decimal(9,1)),
         @variable2;

1 个答案:

答案 0 :(得分:3)

你不需要施放它。如果你使用

0.0

而不是

0

那么你将有一个代表零的十进制数。