Click here to Skip to main content
Click here to Skip to main content

Tagged as

UNION ALL between Two CTEs

, 27 Aug 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Hello, Folks
 
You may Have tried to Apply Union All betwenn two CTEs.
 
For Example,
If you Have two Tables Named TableA and TableB
 
WITH CTE_TableA
AS
(
SELECT * FROM TableA
)
 
UNION ALL
 
WITH CTE_TableA
AS
(
SELECT * FROM TableA
)
 
Then Above SQL Statement Will be result into Error.
 
Now To Make Union Of Two CTEs, Follow Below Code Snippets,
 
WITH CTE_TableA
AS
(
SELECT * FROM TableA
),CTE_TableB
(
SELECT * FROM TableB
)
 
SELECT * FROM CTE_TableA
UNION ALL
SELECT * FROM CTE_TableB
 

Happy Coding !!!

License

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

Share

About the Author

Hiren solanki
Software Developer
India India
He is a Smart IT devloper with Few years of Expeariance But having Great command on ASP.net,C#,SQL Query,SSRS,Crystal Reports
 
Apart from that He Loves multimedia work too, Master of Adobe photoshop, Illustrator, CSS , HTML and all things.
 
He is Currently working in Microsoft Dynamics CRM and Having Nice Expearince with CRM. CRM Rocks!!!

Comments and Discussions

 
GeneralReason for my vote of 5 Good Example. PinmemberNMehta8321-Sep-10 20:44 
GeneralThanks for your comment @linuxjr PinmemberHiren Solanki29-Aug-10 21:33 
GeneralReason for my vote of 5 Thanks for sharing this tip. Pinmemberlinuxjr29-Aug-10 8:12 
GeneralThanks, Small but nice Tip/Trick. PinmemberHiren Solanki26-Aug-10 20:47 
GeneralReason for my vote of 5 good one.. PinmemberSandeep Ramani26-Aug-10 20:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141216.1 | Last Updated 27 Aug 2010
Article Copyright 2010 by Hiren solanki
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid