Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 UNION ALL in a STORED PROCEDURE??

Author  Topic 

Shanew
Starting Member

20 Posts

Posted - 2009-05-21 : 16:42:55
Is it possible to use UNION ALL in a SP to get 2 or more select statements to return data?

Select Fname, Lanme, DOB
from CUS
where fanme = ‘Jim’
UNION ALL
Select Fname, Lanme, DOB
from EMP
where fanme = ‘bob’

I have tried this and get error, the SP not liking UNION..


Thanks for the help.
Shane

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2009-05-21 : 16:59:37
I think your error is because you typed fname as fanme and also lname as lanme. There is nothing that prevents you from doing a union inside of a stored procedure.


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page
   

- Advertisement -