Link to home
Start Free TrialLog in
Avatar of tmajor99
tmajor99

asked on

SQL - Appending data from another table with different column names

how can i append data from another table with different column names..  

Table 1:                                        Table 2:

Group         ID                              SectionGroup            PartID
--------      --------                     ----------------         -----------
100             A                                300                            C
200             B

Expected Result:

Group         ID
-------       -----
100             A
200             B
300             C
ASKER CERTIFIED SOLUTION
Avatar of Nakul Vachhrajani
Nakul Vachhrajani
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Just fyi, you don't need the column names on the second(+) query in a UNION, SQL uses the names from the first query.  This is fine:


SELECT [GROUP] AS 'Group',[ID] AS 'Id'

FROM dbo.Table1

UION

SELECT [SectionGroup], [PartId]

FROM dbo.Table2