Need help with CASE statement

I have read CASE syntax, but I am still confuse.  I want to write a CASE base on targetID as follow:

targetID = 1
FabricToSend="1 yard"

targetID = 2
FabricToSend = "2 yard"

i have no clue on how to start. :(  
can someone guide me?

thanks
aspnewbie09Asked:
Who is Participating?
 
Aneesh RetnakaranConnect With a Mentor Database AdministratorCommented:
SELECT FabricToSend = CASE (TargetID) when 1 then '1 yard' when 2 then '2 Yard' else null end


or


SELECT  FabricToSend =  = CAST (TargetID as varchar)+ ' yard'
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
The latter needs to be
SELECT  FabricToSend = CAST (TargetID as varchar)+ ' yard'
of course (single equal sign).
And CASE works without those parens, they are not needed.
0
 
tigin44Commented:
SELECT CASE WHEN targetID = 1 THEN '1 yard'
                  WHEN targetID = 2 THEN '2 yard'
                  ELSE ''
            END AS FabricToSend
0
 
aspnewbie09Author Commented:
instruction not accurate.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.