Skip to content

Instantly share code, notes, and snippets.

@HammadMaqbool
Last active April 5, 2020 07:54
Show Gist options
  • Save HammadMaqbool/88d630c40a1e85d84d2b1f9d40bcb603 to your computer and use it in GitHub Desktop.
Save HammadMaqbool/88d630c40a1e85d84d2b1f9d40bcb603 to your computer and use it in GitHub Desktop.
Attribute name availablity checking
/*Check Attribute name availablity*/
SELECT TABLE_NAME FROM   DataBaseName_Here.INFORMATION_SCHEMA.COLUMNS WHERE  COLUMN_NAME = ‘Name'
--To check all the tables available in the Database
SELECT TABLE_NAME, TABLE_TYPE FROM DataBaseName_Here.INFORMATION_SCHEMA.TABLES ORDER BY TABLE_NAME
--To Get the list of columns
SELECT COLUMN_NAME FROM DataBaseName_Here.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Table Name here'
/*Queries to get all the data*/
SELECT * FROM INFORMATION_SCHEMA.TABLES
SELECT * FROM INFORMATION_SCHEMA.COLUMNS
SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
/*You need to follow this tutorial to learn the usage of these
queries
link of the tutorial: https://youtu.be/4uvZtmRWS44*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment