Menu ▼



Posted By :
avatarmrkraju
Total Views : 154

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'



If you want to get the names of all tables, views, stored procedures or functions then use the below queries

SELECT name FROM sys.sysobjects WHERE xtype = 'U'

SELECT name FROM sys.sysobjects WHERE xtype = 'V'

SELECT name FROM sys.sysobjects WHERE xtype = 'P'

SELECT name FROM sys.sysobjects WHERE xtype = 'FN'






comments powered by Disqus


Search dotnetlearners.com