Union All Error

The stored procedure that I attached was running fine until I added the last two queries to the CT section. The addition in for Bell Nursery. When I add the queries I get “Incorrect Syntax near the keyword ‘Union’ “, when I try to compile the SP.

The only way to get read of the error in to comment ( as I did ) the new addition.

Is there a limit on the number of Unions I can use in a SP?
Union-Problem.sql
GadFriedmanAsked:
Who is Participating?
 
Simone BSenior E-Commerce AnalystCommented:
You need to remove the "order by" clause from the previous select:

order by bill_id,year,month

--/*

Union all

----------------------------------------------------------------------------

--Bell Nursery
0
 
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
Hi,

Just remove order by or move it to last section


--order by bill_id,year,month

Thanks
0
 
Simone BSenior E-Commerce AnalystCommented:
Move it to the end of the last select.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.