Thursday, 7 August 2014

Count total number of Tables, Stored Procedure, Triggers, Views

Count total number of tables 
 
Suppose you want to count the number of tables in a database. It's quiet simple. Just use the information_schema.tables

The below query will return you the count of the tables in the database .
 
USE  YOURDBNAME
select count(*) as TablesCount from sys.tables
 
Count total number of stored procedure
USE  YOURDBNAME
select count(*) as ProceduresCount from sys.procedures
 
Count total number of  triggers
USE  YOURDBNAME
SELECT count(*) AS MyTriggers FROM sys.triggers
 
Count total number of tables  views
USE  YOURDBNAME
SELECT count(*) AS MyViews FROM sys.views

No comments:

Post a Comment