|
Posted by Jack Vamvas on 03/01/06 16:20
Do something like
select table_name, column_name, ordinal_position, data_type
from information_schema.columns WHERE table_name = 'myTable1'
AND column_name NOT IN (
select table_name, column_name, ordinal_position, data_type
from information_schema.columns WHERE table_name = 'myTable2')
This will give you the columns of 'myTable1' not in 'myTable2'
and you do vica versa to see what columns are in 'myTable2' but not in
'myTable1'
From this combined list , you can create your ALTER TABLE statements.
--
Jack Vamvas
___________________________________
Receive free SQL tips - www.ciquery.com/sqlserver.htm
"Shwetabh" <shwetabhgoel@gmail.com> wrote in message
news:1141205791.768559.167490@p10g2000cwp.googlegroups.com...
> Hi,
>
> I have a table which I want to alter to add the data from another
> table.
> Now both these tables have a few columns which are same. Now,
> I want the system to be such that only the unique columns can be
> added to the first table.
>
> How can I accomplish this in SQL?
>
[Back to original message]
|