Avatar of brgdotnet
brgdotnet
Flag for United States of America asked on

IF else end structure when doing an IF EXISTS statement

I want like an if then else structure when I use an IF EXISTS CLAUSE. In that case would the code below be correct where I have two BEGIN END statements ?
---------------------------------
IF  EXISTS ( SELECT Code from zoop where Code = @newPLAYERId)
BEGIN
update zoop
    set Code = '####'  
    from zoop t
    where t.DateEntered > ( select min(x.DateEntered) from zoop x ) -- AND SUBSTRING(t.Code,1,1) = 'A'
END
ELSE
BEGIN

END
Microsoft SQL Server

Avatar of undefined
Last Comment
knightEknight

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
knightEknight

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy