Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting PKs of Tables
Message
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Getting PKs of Tables
Miscellaneous
Thread ID:
00755682
Message ID:
00755682
Views:
45
In Oracle, the following SQL will return a cursor of tables and what columns are indexed as the Primary Key for each table. What SQL will return the same for SQL Server? TIA!
select
  B.Constraint_Type,
  A.Index_Name,
  A.Table_Name,
  A.Column_Name
 from
  User_Constraints B, User_Ind_Columns A
 where A.Index_Name = B.Constraint_Name
   and B.ConstraintType = 'P'
 order by A.Table_Name
Mark McCasland
Midlothian, TX USA
Next
Reply
Map
View

Click here to load this message in the networking platform