Know relationships between all the tables of database in SQL Server

前端 未结 7 2042
灰色年华
灰色年华 2020-11-28 05:00

I wish to all know how the tables in my database are related to each other (i.e PK/FK/UK) and hence i created a database diagram of all my tables in SQL Server. The diagram

7条回答
  •  佛祖请我去吃肉
    2020-11-28 05:46

    select * from information_schema.REFERENTIAL_CONSTRAINTS where 
    UNIQUE_CONSTRAINT_SCHEMA = 'TABLE_NAME' 
    

    This will list the column with TABLE_NAME and REFERENCED_COLUMN_NAME.

提交回复
热议问题