Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UNION Wizard

Status
Not open for further replies.
Jan 31, 2010
21
0
0
GB
Hello!

Anyone know of a tool (within SSMS / 3rd party) to take the pain out of setting up unions queries with a large number of columns/sources...

It would be great to be able to 'drag and drop' field names into columns ie:

Field1 Field2 Field3
CustID CustName Type < source 1
Customer name CustType < source 2
C_ID C_Name C_Type < source 3
CID name null < source 4

My dream would be for the columns to be lined up so it's easily recognisable that the fields are aligned correctly and easy to add 'padding fields' (null) where a field is not present in one particular source... it would also check the datatypes and collation are the same across all aligned fields.

I know all of this is 'easy' to do 'by hand' but a tool would take the pain away.... anyone have any tel-tips??

Thanks!
 
If I understand correctly, in SQL Server 2005 and greater you can right-click the table and choose Script Table as -> SELECT to -> New Query Editor Window. This formats the text the way you want. If you are writing a UNION ALL query then copy and past the same script underneath and insert the UNION ALL clause in between. You can also drag fields from the Columns branch under the table, in SSMS Object Explorer, to the quey window, mind you.

MCP SQL Server 2000, MCTS SQL Server 2005, MCTS SQL Server 2008 (DBD, DBA)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top