Skip to content
Advertisement

SQL Server Information_Schema

I want to check a table’s primary key by SQL statements, I use below SQL:

But I just got the constraint name but I want to see which column(s) contained in the primary key, is there a way to do that?

Advertisement

Answer

Just join against INFORMATION_SCHEMA.KEY_COLUMN_USAGE:

Result:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement