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

Flow Control in proc programming - IF...ELSE 1

Status
Not open for further replies.

daglugub37

Technical User
Joined
Oct 21, 2003
Messages
201
Location
US
This is currently working for me:
IF condition
BEGIN
Statements
END
ELSE
BEGIN
Statements
END


However I would like to get something like this to work with an IF nested:
IF condition
BEGIN
Statements
IF CONDITION
BEGIN Statements
RETURN
END
END
ELSE
BEGIN
Statements
END

I can't seem to get the syntax right; keeps erroring on the ELSE. Do I need some parens or brackets or something?
 
Your syntax should be fine. The return statement in the nested IF might be causing you a problem but it shouldn't be. I've used that exact syntax many times.

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(Not quite so old any more.)
 
thanks you were right, and I guess I was too....but I did not have my code formatted like my example....I was trying to run the 2nd IF statements before the 1st BEGIN.

All set now thanks again for confirming the correct syntax template
 
that will definettly cause a problem.

Glad it's working.

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(Not quite so old any more.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top