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!

Access IIf statement in SQL

Status
Not open for further replies.

sqlJunior

Technical User
Sep 22, 2002
123
0
0
TH
I am upsizing from Access to SQL. In Access I had the following Query field:-
TagNo: IIf([Tag].[ID] Like "********x",2,1)

How can I get an SQL query to Substitute a Tag ID with '2' and other Tag Id's with '1'
 
You can use CASE statement

DECLARE @Field tinyint
SELECT @Field=1
select case @Field
when 1 then 'X'
when 2 then 'Y'
else 'Z'
end WENG YAN
 
Thanks Weng Yan, i am trying to get this to work but does the query designer support the Case statement?
 
No it does not. You will have do create the view in code. What I usually do is create the entire rest of the view using the designer and then add the case statements after wards un the edit window without the designer.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top