How to get a list of tables with composite primary key in SQL Server? -


how create query gives me list of tables composite primary key in sql server? maybe using sys.tables or information_schema.tables or else?

you can dig info in information_schema.table_constraints , information_schema.constraint_column_usage, checking multiple rows of primary key constraints on table, like;

select col.table_name  information_schema.table_constraints tc  join information_schema.constraint_column_usage col   on col.constraint_name = tc.constraint_name  , col.table_name = tc.table_name  , tc.constraint_type = 'primary key ' group col.table_name having count(*) > 1 

an sqlfiddle test with.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -