1

我正在尝试在更新查询中使用大小写,它给了我一个错误,即大小写附近的语法不正确。我不知道在哪里?!这是在 SQL 2005 中

我将日期发送到存储过程。如果发送的日期是 '01/01/1905',它必须保存 null 否则输入的实际日期。我真的不确定这个声明有什么问题。

Update Manifest set Notes = @Notes, IsCustom = @IsCustom,
CASE WHEN @ProofSent = CONVERT(datetime, '01/01/1905') THEN NULL ELSE @ProofSent END,
CASE WHEN @ProofApproved = CONVERT(datetime, '02/01/1905') THEN NULL ELSE @ProofApproved END 

提前致谢!

4

2 回答 2

1

您尚未声明应将其设置为哪一列:

Update Manifest set Notes = @Notes, IsCustom = @IsCustom,
    ProofSent = CASE WHEN @ProofSent = CONVERT(datetime, '01/01/1905') THEN NULL ELSE @ProofSent END,
    ProofApproved = CASE WHEN @ProofApproved = CONVERT(datetime, '02/01/1905') THEN NULL ELSE @ProofApproved END
于 2012-11-29T20:29:04.767 回答
0

一定是这样的:

Update Manifest set Notes = @Notes, IsCustom = @IsCustom,
Column1 = 
    CASE WHEN @ProofSent = CONVERT(datetime, '01/01/1905') THEN NULL 
    ELSE @ProofSent END,
Column2=
    CASE WHEN @ProofApproved = CONVERT(datetime, '02/01/1905') THEN NULL 
    ELSE @ProofApproved END 
于 2012-11-29T20:31:23.567 回答