SELECT * INTO TABLE1
FROM Table2
UNION ALL
SELECT * FROM Table3;
GO
I am using this query to stack two tables together into one table.
These tables should have the columns in the exact same order for this query to execute succesfullysuccessfully. I
I am wondering whetherif there is a trick we can do so that it works iregardlessregardless of the column order, I am surprised if. Is there is not a way for "SQLto instruct SQL Server Mgmt" to do findautomatically line up the corresponding columncolumns from table2, in table1, if they have the sameboth tables by name. and perform the UNION
?
In SAS, the trick is to write a "OUTER UNION CORR"OUTER UNION CORR
query, for example.
Thanks a billion!