Help to convert a IIf statement to SQL query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

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

Many thanks...
 
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
 
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...
 
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...
 
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...
 
I may be wrong but MS-SQL IIF is only available in Analysis Service and not
in general T-SQL.
 
Back
Top