这个t-sql语法有什么问题?

时间:2013-06-24 13:16:07

标签: sql-server tsql

我正在尝试在sql server上运行Access中编写的sql。该查询在第4行引发语法错误:

UPDATE mytablename SET 
table.[Specimen Collection Date 1] = 
IIf(
[Specimen Collection Date 2] Is Not Null,   //incorrect syntax near is
[Specimen Collection Date 2],
IIf([Specimen Collection Date 2] Is Null,[Specimen Collection Date 3] Is Not Null))

似乎有效的列名[Speciment Collection Date]似乎是有效的expression

我错过了什么?

2 个答案:

答案 0 :(得分:1)

sql中没有IIf。查找case when tsql约定。

http://msdn.microsoft.com/en-us/library/ms181765.aspx

答案 1 :(得分:0)

您不需要在列定义中包含TABLE。数据库从“Update TABLE”语句中知道它是什么表。