How to get primary key of a table from SQL Server

by

SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE OBJECTPROPERTY(OBJECT_ID(CONSTRAINT_SCHEMA + '.' + CONSTRAINT_NAME), 'IsPrimaryKey') = 1
AND TABLE_NAME = 'my_table_name' AND TABLE_SCHEMA = 'my_schema_name'

See also:

How to get primary key of a table from PostgreSQL

How to get primary key of a table from SQLite

How to get primary key of a table from MySQL

How to get primary key of a table from DB2

How to get primary key of a table from Oracle

Some SQL Server tools you can try: https://www.withdata.com/sql-server/