SoftadminGuide.Table_PrimaryKeyInfo

Type: Table-valued function

Provides information about the primary key of a given table.

Parameters

@TableId mandatory int
ObjectId of a table.

Resultsets

Resultset: Primary key info

Table count: repeated exactly once
Row count: exactly one row
Columns
IsComposite mandatory bit

1 if table has more than one primary key column, 0 otherwise.

IsMissing mandatory bit

1 if no primary key exists, 0 otherwise.

IsIdentity mandatory bit

1 if primary key has one column, with the identity propery. 0 if primary key is missing, has one column without identity or is a composite key with identity on one of its columns.

HasDefault mandatory any

1 if primary key has a default constraint, and is not composite. 0 otherwise.

ColumnName mandatory sysname

The name of the single primary key column. NULL if primary key is missing or is composite.

ColumnId mandatory int

The column_id (from sys.columns) of the single primary key column. NULL if primary key is missing or is composite.

DataType mandatory string

Data type of the single primary key column. NULL if primary key is missing or is composite.