SQL query specifies table FOREIGN KEY constraints

Source: Internet
Author: User
Query specifies table foreign KEY constraints
Selecta.name as constraint name, object_name (b.parent_object_id) as foreign key table, d.name as foreign key column, object_name (b.referenced_object_id) As main health table, C.name as primary key column from Sys.foreign_keys Ainner join Sys.foreign_key_columns B on A.object_id=b.constraint_object_idinner join Sys.columns C on b.parent_object_id=c.object_id and b.parent_column_id=c.column_id inner joins sys.columns D on B.referenc ed_object_id=d.object_id and b.referenced_column_id=d.column_id where object_name (b.referenced_object_id) = ' table name to query ' ;

SQL query specifies table FOREIGN KEY constraints

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.