Thursday, April 21, 2022

SQL Server : get count of tables, views, etc.

 

Get total number of tables, views, stored procedures and functions count and names in sql server

Below query will return the total number of tables in sql server


SELECT count(name) as tablecount FROM sys.sysobjects WHERE xtype = 'U'


Below query will return the total number of views in sql server


SELECT count(name) as viewscount FROM sys.sysobjects WHERE xtype = 'V'


Below query will return the total number of stored procedures in sql server


SELECT count(name) as spcount FROM sys.sysobjects WHERE xtype = 'P'


Below query will return the total number of functions in sql server


SELECT count(name) as fncount FROM sys.sysobjects WHERE xtype = 'FN'

No comments: