In this article I am going to explain How to get or find or retrieve the list all Primary Key, Foreign Key and Unique Key into the database.
There is Two difference method to get/find/retrieve the list all Primary Key, Foreign Key and Unique Key into the database.
SELECT [CONSTRAINT_CATALOG] AS 'DatabaseName'
,[CONSTRAINT_SCHEMA] AS 'KeySchemaName'
,[CONSTRAINT_NAME] AS 'KeyName'
,[TABLE_NAME] AS 'TableName'
,[COLUMN_NAME] AS 'ColumnName'
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
OUTPUT: