Getting Primary key associated with Tables.

vishalneeraj-24503
Posted by vishalneeraj-24503 under Sql Server category on | Points: 40 | Views : 327
Write below query to get Primary keys:-
select tab.table_name,col.column_name  
from
information_schema.table_constraints tab,
information_schema.constraint_column_usage col
where
col.constraint_name = tab.constraint_name
and col.table_name = tab.table_name
and constraint_type = 'primary key'
order by tab.table_name;

Comments or Responses

Login to post response