How to determine which columns are shared between two tables?

后端 未结 8 1362
时光取名叫无心
时光取名叫无心 2021-02-01 09:10

Very new to SQL Sever here... I understand the concept of joining tables, etc. but what is the easiest way to determine which columns are shared?

Say for instance we ha

8条回答
  •  没有蜡笔的小新
    2021-02-01 09:58

    Use following query (name used to show coman columns list)

    select name from syscolumns s1 where id = object_id('table1') and            exists(select 1 from syscolumns s2 where s2.name = s1.name and s2.id = object_id('table2'))
    

提交回复
热议问题