Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT ccu.COLUMN_NAME, ccu.CONSTRAINT_NAME
- FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS tc
- INNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE AS ccu
- ON tc.CONSTRAINT_NAME = ccu.CONSTRAINT_NAME
- WHERE tc.TABLE_CATALOG = 'Your_Catalog' -- replace with your catalog
- AND tc.TABLE_SCHEMA = 'dbo' -- replace with your schema
- AND tc.TABLE_NAME = 'Your_Table' -- replace with your table name
- AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement