bernie2436
bernie2436

Reputation: 23901

What is wrong with this t-sql syntax?

I am trying to run sql written in Access on sql server. The query is throwing a syntax error on line 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))

It seems like a valid column name [Speciment Collection Date] seems like a valid expression.

What am I missing?

Upvotes: 0

Views: 97

Answers (2)

JC Ford
JC Ford

Reputation: 7066

There is no IIf in sql. Look up the case when tsql convention.

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

Upvotes: 1

Bill Gregg
Bill Gregg

Reputation: 7147

You don't need to include the TABLE in your column definition. The DB knows what table it is from your "Update TABLE" statement.

Upvotes: 0

Related Questions