RSS feed

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?

 

Database Attachment Error: Error 602: Could not find row in sysindexes for database ID 27, object ID 1, index ID 1 >>

<< 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

*Name:
*Comment:
You can use HTML tags here.
*Code: Please enter the sum of 5+2