select 'TABLE' , count(*) 'TABLE COUNT' from sysobjects WHERE xtype='U'
UNION ALL
select 'VIEW' , count(*) 'TABLE COUNT' from sysobjects WHERE xtype='V'
UNION ALL
select 'PROCEDURE' , count(*) 'TABLE COUNT' from sysobjects WHERE xtype='P'
UNION ALL
select 'FUNCTION' , count(*) 'TABLE COUNT' from sysobjects WHERE xtype='FN'
UNION ALL
SELECT 'INDEX' , count(*) 'TABLE COUNT' FROM sys.indexes si
JOIN sys.objects so ON
si.object_id = so.object_id
WHERE so.type = 'U'
AND si.type <> 0In this code you can count object in SQL Server.
