Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Statement

Status
Not open for further replies.

jnavarro

Programmer
Dec 1, 2003
89
US
I am receiving this error everytime I try running this query

Error in list of function arguments: '=' not recognized.
Unable to parse query text.

What I am trying to do is compare the value in one field and change the value based on the condition. List below is my SQL

SELECT Div, IIf([Div] = 'LT', 'Hello', 'Jack') AS test
FROM tblAI

Can someone help me
 
There's no IIF in SQL Server (which is what this forum is for).

It looks like you need to post in a Microsoft Access forum.

-SQLBill

Posting advice: FAQ481-4875
 
I am using sql I forgot to remove the extra "I". However, I am still receiving the same error.
 
The SQL Server equivalent is the case statement.
 
That's still not Microsoft SQL Server syntax. The only IF usage we have is:

IF (SELECT [Div] FROM Tablename) = 'LT'
BEGIN
PRINT 'Hello' 'Jack'
END
ELSE
PRINT 'Not Found'

Refer to the BOL for more examples.

-SQLBill

Posting advice: FAQ481-4875
 
Why is it not syntax? Do you mean it depends on the version?
 
Katy44,

I wasn't talking about your post. I was commenting about jnavarro's post saying he 'forgot to remove the extra "I"'.

As you posted, if you want to use IF in a SELECT you need to use CASE. I showed him how SQL Server uses IF.

-SQLBill

Posting advice: FAQ481-4875
 
Just a note to avoid confusion. IIF() is available for use in SQL Reporting Services expressions, but it is not T-SQL, it is Visual Basic .NET. And it can only be used in textbox expressions, not in the DataSets which use T-SQL for their queries.

Clear as mud, right? @=)





Catadmin - MCDBA, MCSA
"If a person is Microsoft Certified, does that mean that Microsoft pays the bills for the funny white jackets that tie in the back???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top