<CODE>
Select Results.custID
From Results
If (Results.custID = DRCMGO.custID)
Begin
Update Results
SET Results.DRCMGO = 'Y'
END
ELSE
Begin
Update Results
SET Results.DRCMGO = 'N'
END
<CODE>
I'm trying to do an IF / ELSE statement:
-- if the custIDs in my Results table and my DRCMGO table match then I want to set DRCMGO to Y
-- if they don't match I want to set it to N
What is wrong with this syntax. If someone could let me know i would greatly appriciate it (I'm doing it as SQL Books Online is telling me to)
Thanks in advance everyone.
RB
In the if statment you are asking if the entire column results.custID = drcmgo.custID.
I think you want something like this
update results
set results.drcmgo = 'y'
from results
join drcmgo on drcmgo.custid = results.custid
update results
set results.drcmgo = 'n'
from results, drcmgo
where drcmgo.cust <> results.custid
No comments:
Post a Comment