Skip to content

Instantly share code, notes, and snippets.

@arturfsousa
Last active December 5, 2017 18:47
Show Gist options
  • Save arturfsousa/e8bfcbe19a8efa6846b39a357d78001c to your computer and use it in GitHub Desktop.
Save arturfsousa/e8bfcbe19a8efa6846b39a357d78001c to your computer and use it in GitHub Desktop.
SELECT Col.Column_Name from
INFORMATION_SCHEMA.TABLE_CONSTRAINTS Tab,
INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE Col
WHERE
Col.Constraint_Name = Tab.Constraint_Name
AND Col.Table_Name = Tab.Table_Name
AND Constraint_Type = 'PRIMARY KEY'
AND Col.Table_Name = '<your table name>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment