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
 General SQL Server Forums
 New to SQL Server Programming
 IFF

Author  Topic 

DavidChel
Constraint Violating Yak Guru

474 Posts

Posted - 2009-01-29 : 11:39:58
I'm looking at someone else's code which looks like this:


SELECT DBO_ARITEM.FCINVOICE
AS [INVOICE #],
DBO_ARITEM.FITEM
AS [INVOICE ITEM],
DBO_ARMAST.FINVDATE
AS [INVOICE DATE],
LEFT([FSOKEY],6)
AS [SO-NUMBER],
IIF([FSOKEY] = " ","",CINT(STRREVERSE(MID(STRREVERSE(MID([FSOKEY],8)),4
)))) AS [SO-LINEITEM],
RIGHT([FSOKEY],3)
AS [SO-ITEM-RELEASE],


Is IFF not supported in SQL 2000? I tried Googling it but came up empty.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-01-29 : 11:45:17
Looks like VB.

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-01-29 : 11:46:00
look also at:
CINT(STRREVERSE(MID(STRREVERSE(MID(...

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-29 : 11:46:37
this seems like an access query. IIF is not supported in sql 2000. the equivalent is CASE WHEN...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-29 : 11:51:33
in sql server, it will become,


SELECT DBO_ARITEM.FCINVOICE
AS [INVOICE #],
DBO_ARITEM.FITEM
AS [INVOICE ITEM],
DBO_ARMAST.FINVDATE
AS [INVOICE DATE],
LEFT([FSOKEY],6)
AS [SO-NUMBER],
CASE WHEN [FSOKEY] = ' ' THEN '' ELSE REVERSE(SUBSTRING(REVERSE(SUBSTRING([FSOKEY],8,LEN([FSOKEY]))),4,LEN(REVERSE(SUBSTRING([FSOKEY],8,LEN([FSOKEY])))))) AS [SO-LINEITEM],
RIGHT([FSOKEY],3)
AS [SO-ITEM-RELEASE],
Go to Top of Page
   

- Advertisement -