?
Solved

Union All Error

Posted on 2012-04-10
3
Medium Priority
?
203 Views
Last Modified: 2012-04-10
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
0
Comment
Question by:GadFriedman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
Simone B earned 2000 total points
ID: 37828511
You need to remove the "order by" clause from the previous select:

order by bill_id,year,month

--/*

Union all

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

--Bell Nursery
0
 
LVL 16

Expert Comment

by:Imran Javed Zia
ID: 37828517
Hi,

Just remove order by or move it to last section


--order by bill_id,year,month

Thanks
0
 
LVL 11

Expert Comment

by:Simone B
ID: 37828524
Move it to the end of the last select.
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question