Pages

Showing posts with label Get column Details. Show all posts
Showing posts with label Get column Details. Show all posts

Wednesday, September 18, 2013

SQL Query to get Column Count & Details of a Database

 
Get Columns Count of all tables in a Database
Select TABLE_NAME as 'All tables', COUNT(*) as 'no. of columns'
From INFORMATION_SCHEMA.COLUMNS
Group By TABLE_NAME
Order By TABLE_NAME
  
Total no. of Columns in a Table:
SELECT count(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'yourTableHere'           
 
Columns Details of a Table: 
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'yourTableHere'
 
All Columns Names of a Table: 
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'yourTableHere'