June 27, 2006 at 7:30 am
Using MS SQL Server 2000, I would like to take the column names and data definitions for one table and superimpose them on another table that has the same number of columns and contains similar data in each of the respective columns. Is there a quick and easy way of doing this?
June 27, 2006 at 2:02 pm
If I understand correctly, you want to SELECT * FROM TABLEB, but have the output reflect the column names of TABLEA. The cleanest way would be to alias the column names:
SELECT COL1B as COL1A, COL2B AS COL2A FROM TABLEB
The lazy way would be:
SELECT COL1A, COL2A FROM TABLEA WHERE 0=1
UNION ALL
SELECT COL1B, COL2B FROM TABLEB
June 27, 2006 at 3:21 pm
If you are talking about adding additional columns from Table A to Table B then I would script Table A (without Drop option, just in case) and copy the script for these columns into Alter Table statement. try on the test server first.
Regards,Yelena Varsha
June 28, 2006 at 5:59 am
Is this what you are looking for...
select * into table2 from table1
will create table2 with same structure and data as table1.
check for indexes and default values in table2
June 28, 2006 at 2:49 pm
I read the question as how do I return two tables that are the same structure as if they were 1 table.
Select * from TableA
UNION ALL
Select * from TableB
jg
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply