Get the App
SLTechnology News&Howtos  ›  Database  › 

How to view primary key columns in SQLServer database

Shulou Source: shulou.com Published: 2022-05-31 19:12:37 09月30日 Update

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

Tags: Data databases questions more help answers easy easy content guys partners methods fragments knowledge articles industry information channels channels analysis Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MySQL Docker Redmi MariaDB