How to view primary key columns in SQLServer database
How to view the primary key column in the SQLServer database? for this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
How to view SQLServer database primary key columns
The following is a reference clip:
SELECT
Sysobjects.name,syscons.name,syscolumns.name
From
Sysobjects
Innerjoinsyscolumns
Onsysobjects.id=syscolumns.id
Leftouterjoin
(select
O.namesTableName
C.NamesColName
From
Sysobjectso
Innerjoinsysindexesi
Ono.id=i.id
And (i.status&0X800) = 0X800
Innerjoinsyscolumnsc1
Onc1.colid