Created
June 26, 2016 14:03
-
-
Save tompazourek/b49f7f02829fa962b2c84f21a779b7ee to your computer and use it in GitHub Desktop.
List foreign keys and primary keys in the database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT OBJECT_NAME(OBJECT_ID) AS NameofConstraint, | |
SCHEMA_NAME(schema_id) AS SchemaName, | |
OBJECT_NAME(parent_object_id) AS TableName, | |
type_desc AS ConstraintType | |
FROM sys.objects | |
WHERE type_desc IN ('FOREIGN_KEY_CONSTRAINT','PRIMARY_KEY_CONSTRAINT') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment