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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIf Condition in sql server

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0

I have tried the following IIf query which is not working

iif(ID_LEVEL='0','1',reverse(substring(reverse(ID_LEVEL),charindex('.',reverse(ID_LEVEL))+1,LEN(ID_LEVEL))) which does not work. Can anybody teel me the right syntax as it gives a syntax error.

if id_level is 0 then return 1 else execute the query :
reverse(substring(reverse(ID_LEVEL),charindex('.',reverse(ID_LEVEL))+1,LEN(ID_LEVEL))
 

There is no IIf in SQL Server. Use the CASE statement instead.

Case ID_LEVEL
When '0' Then '1'
Else reverse(substring(reverse(ID_LEVEL),charindex('.',reverse(ID_LEVEL))+1,LEN(ID_LEVEL)))
End Terry L. Broadbent
Life would be easier if I had the source code. -Anonymous
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top