Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Having a challenge embedding a CTE within IF ELSE END ROUTINE.

Is it feasible

IF

What I have tried:

On going developmental challenge requiring assistance from experts


IF @INDENT ='OPENED'

BEGIN

; WITH CTE AS
(
SELECT FNAME, LNAME FROM TRIAL

),

END

Incorrect syntax near the keyword 'END'

Please assist

Thanks
Posted
Updated 7-May-18 3:27am
v2
Comments
Maciej Los 7-May-18 9:15am    
Not a question at all!
Jochen Arndt 7-May-18 9:45am    
The error message tells you where to look.
It is the comma just before END which separates multiple CTEs but there is none.

Not posted as solution because it is still not valid SQL.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900