CATEGORIES
How to get common columns from two different tables using T-SQL?
Published by: Farhan Ahmed (11/21/2008 4:27:41 AM)
NOV 21 2008
I am facing lots of trouble finding common columns of two tables as I am in Banking sector. there is huge amount of data tables are in here ... as a new comer it is really diffcult to adjust and find common columns to match two tables . so how should this possible to find columns from table?
Most Popular Articles
- SQL Server 2008 Error: is not a valid login or you do not have permission
- Cannot start .aspx
- what is the difference between Text and String Data type in SQL Server
- Error: Microsoft OLE DB Provider for ODBC Drivers error '80004005'
- Why my MS SQL Server 2005 DSN Connection is not Working
<< Can I Add a Column in the Middle of Two other Columns using SQL Command
COMMENT
Name: Farhan Ahmed
select a.name from
(select name from syscolumns where id=object_id(’table1’) ) a
join
(select name from syscolumns where id=object_id(’table2’) )
b on a.name=b.name
This is the one way that I find out common columns from different tables
If some one has any other solution plz do tell me.
Regards
Farhan
Name: Jit
Here is a way to achieve this.
select t1.name from table1 as t1, table2 as t2 where t1.name = t2.name
Name: Farhan Ahmed
Sorry Jit,
But I found some errors with your query.
Thanks
Farhan
Name: Farhan Ahmed
Sorry Jit,
But I found some errors with your query. may be I am using SQL SERVER 2000....
Thanks
Farhan
Name: brahmam
thanks