ObjectCount In Sql server

  1. select 'TABLE' , count(*) 'TABLE COUNT' from sysobjects WHERE xtype='U'  
  2. UNION ALL  
  3. select 'VIEW' , count(*) 'TABLE COUNT' from sysobjects WHERE xtype='V'  
  4. UNION ALL  
  5. select 'PROCEDURE' , count(*) 'TABLE COUNT' from sysobjects WHERE xtype='P'  
  6. UNION ALL  
  7. select 'FUNCTION' , count(*) 'TABLE COUNT' from sysobjects WHERE xtype='FN'  
  8. UNION ALL  
  9. SELECT 'INDEX' , count(*) 'TABLE COUNT' FROM sys.indexes si  
  10. JOIN sys.objects so ON   
  11. si.object_id = so.object_id  
  12. WHERE so.type = 'U'  
  13. AND si.type <> 0