Help to convert a IIf statement to SQL query

Z

Zirc

Hi all
can someone help me to convert this "access" query:

IIf([Diff]<>0;"Error";"")

Many thanks...
 
D

Duane Hookom

convert to what? Netiquette suggests that you don't expect us to read your
subject in order to understand your question.

You can try:

CASE WHEN Diff <>0 THEN 'Error' ELSE '' END
 
R

Ricardo

Is there a way to get the query running both in Access and SQL Server?

Ricardo



"Duane Hookom" escreveu:
convert to what? Netiquette suggests that you don't expect us to read your
subject in order to understand your question.

You can try:

CASE WHEN Diff <>0 THEN 'Error' ELSE '' END

--
Duane Hookom
MS Access MVP
--

Zirc said:
Hi all
can someone help me to convert this "access" query:

IIf([Diff]<>0;"Error";"")

Many thanks...
 
M

[MVP] S.Clark

Looking at BOL, it shows that an IIF function exists. Maybe post the entire
SQL Statement and the error that you are receiving to see if someone can
help.

--
Steve Clark, Access MVP
FMS, Inc.
www.fmsinc.com/consulting

Ricardo said:
Is there a way to get the query running both in Access and SQL Server?

Ricardo



"Duane Hookom" escreveu:
You can try:

CASE WHEN Diff <>0 THEN 'Error' ELSE '' END

--
Duane Hookom
MS Access MVP
--

Zirc said:
Hi all
can someone help me to convert this "access" query:

IIf([Diff]<>0;"Error";"")

Many thanks...
 
R

Ricardo

Running the NorthWind database and the following query:

SELECT ProductName, IIF(Discontinued = 0, 'No', 'Yes') AS Discontinued
FROM Products

I get the error: "Incorrect syntax near =".

What's the problem?

Ricardo



"[MVP] S.Clark" escreveu:
Looking at BOL, it shows that an IIF function exists. Maybe post the entire
SQL Statement and the error that you are receiving to see if someone can
help.

--
Steve Clark, Access MVP
FMS, Inc.
www.fmsinc.com/consulting

Ricardo said:
Is there a way to get the query running both in Access and SQL Server?

Ricardo



"Duane Hookom" escreveu:
You can try:

CASE WHEN Diff <>0 THEN 'Error' ELSE '' END

--
Duane Hookom
MS Access MVP
--

Hi all
can someone help me to convert this "access" query:

IIf([Diff]<>0;"Error";"")

Many thanks...
 
V

Van T. Dinh

I may be wrong but MS-SQL IIF is only available in Analysis Service and not
in general T-SQL.
 
Top