Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 syntax error in IIF select stmt

Author  Topic 

rum23
Yak Posting Veteran

77 Posts

Posted - 2009-05-28 : 04:23:24

SELECT IIf(Month(PaidDate) > 9 , Year(PaidDate) + 1 , Year(PaidDate)) AS PaidMonth FROM Table1

i get "Incorrect syntax near '>'.". What is wrong in my sql? Please help. Thanks!

xxxxxxxxxx
Starting Member

1 Post

Posted - 2009-05-28 : 04:37:15
This is not MS SQL syntax. You probably use Accesss. SQL server don't have IIF function implemented. You should use CASE command.
Go to Top of Page

f4n92x
Starting Member

1 Post

Posted - 2009-05-28 : 04:37:57
are u querying in SQL Server 2005 or in Access?

SQL Server 2005 do not recognise the function IIF, if i remember correctly.
You can change the query to:

select case when month(paiddate) > 9 then year(paiddate) + 1 else year(paiddate) end as paidmonth from Table1
Go to Top of Page
   

- Advertisement -