Reply to Re: Checking for existing column

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация