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

Using IF in SQL View

Status
Not open for further replies.

aggieval

Programmer
May 23, 2002
25
0
0
US
I am completely new to SQL, so I may bew doing this all wrong, so any advice would be incredibly helpful. That being said, here is my problem:

I have converted and Access Database to SQL server, but am continuing to use my Access front end for the time being. I am converting any slow queries and reports to get the data from a View. In some of these queries I am using an IIF statemnent (for example: iif (value = -1, "Exp", ""). Is there a way to use a statment like this in a view or a simpler way to accomplish what I am trying to do.

Thanks in advance for your help.

Tracy
 
Use a CASE expression:

Code:
SELECT CASE WHEN value = -1 THEN 'Exp' ELSE '' END AS column_name
FROM table_name

--James
 
Thanks a lot James. I got that to work. I really appreciate your help.

Tracy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top