Last active
March 15, 2018 09:58
-
-
Save tilakpatidar/92bcd65da79c7df3a647f226de080f36 to your computer and use it in GitHub Desktop.
Common SQL server queries
This file contains hidden or 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
-- Finding difference in values for some key | |
SELECT * from A a,b WHERE a.id = b.id AND NOT a.name = b.name; | |
--Returns one row for each CHECK, UNIQUE, PRIMARY KEY, and/or FOREIGN KEY | |
SELECT * | |
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS | |
WHERE CONSTRAINT_NAME='XYZ' | |
--Returns one row for each FOREIGN KEY constrain | |
SELECT * | |
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS | |
WHERE CONSTRAINT_NAME='XYZ' | |
--Returns one row for each CHECK constraint | |
SELECT * | |
FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS | |
WHERE CONSTRAINT_NAME='XYZ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment