Friday, December 16, 2016

Count the number of tables in the SQL Server database.

Count the number of tables in the SQL Server database:

Using below SQL query to fetch the total number of table in the SQL Server database:

Use Your_DataBaseNameSelect * from INFORMATION_SCHEMA.TABLES

Here you get total count of table(base table, view).



If you want fetch count of only TABLE in the database, write below query:

Select * from INFORMATION_SCHEMA.TABLESWhere TABLE_TYPE='BASE TABLE'



If you want fetch count of only VIEW count in the database, write below query:

Select * from INFORMATION_SCHEMA.TABLESWhere TABLE_TYPE='VIEW'

No comments:

Post a Comment