September 18, 2015 at 1:04 pm
Why isn't CASE supported for flow control in T-SQL ?
I have to do this ?:
IF @xyz = 1 THEN
EXEC dbo.PROC1
ELSE IF @xyz = 2 THEN
EXEC dbo.PROC2
ELSE
EXEC dbo.PROC3
END
September 18, 2015 at 1:06 pm
Because T-SQL doesn't like to have flow control.
Don't forget to remove THEN, this isn't VB. 😛
September 18, 2015 at 3:45 pm
Luis Cazares (9/18/2015)
Because T-SQL doesn't like to have flow control.
Why exactly ?
BTW: Thanks for that "THEN" but IMHO that should be optional.
September 18, 2015 at 3:48 pm
Unlike Oracle where CASE can be used for control of flow, T-SQL does not have it overloaded in that manner. Why? I don't know, you'd actually need to go back Sybase Engineers to figure that one out.
September 22, 2015 at 12:27 pm
You can use this type of conditional logic in stored procedures. Dunno if that's stating the obvious or not.
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply