I have database Test1
in SQL Server 2008 R2. On the live server I took backup from there and restore it at our local machine as Test2
and added som
I now use the below, based on Milica's answer with some extra types, default value and sorted by count.
SELECT 'Count' = COUNT(*), 'Type' = CASE type
WHEN 'AF' THEN 'Aggregate function (CLR)'
WHEN 'C' THEN 'CHECK constraints'
WHEN 'D' THEN 'Default or DEFAULT constraints'
WHEN 'F' THEN 'FOREIGN KEY constraints'
WHEN 'FN' THEN 'Scalar functions'
WHEN 'FS' THEN 'Assembly (CLR) scalar-function'
WHEN 'FT' THEN 'Assembly (CLR) table-valued function'
WHEN 'IF' THEN 'Inlined table-functions'
WHEN 'IT' THEN 'Internal table'
WHEN 'K' THEN 'PRIMARY KEY or UNIQUE constraints'
WHEN 'L' THEN 'Logs'
WHEN 'P' THEN 'Stored procedures'
WHEN 'PC' THEN 'Assembly (CLR) stored-procedure'
WHEN 'PG' THEN 'Plan guide'
WHEN 'PK' THEN 'PRIMARY KEY constraint'
WHEN 'R' THEN 'Rules'
WHEN 'RF' THEN 'Replication filter stored procedures'
WHEN 'S' THEN 'System tables'
WHEN 'SN' THEN 'Synonym'
WHEN 'SO' THEN 'Sequence object'
WHEN 'SQ' THEN 'Service queue'
WHEN 'TF' THEN 'Table functions'
WHEN 'TR' THEN 'Triggers'
WHEN 'U' THEN 'User tables'
WHEN 'UQ' THEN 'UNIQUE constraint'
WHEN 'V' THEN 'Views'
WHEN 'X' THEN 'Extended stored procedures'
ELSE type
END
FROM sys.objects
GROUP BY type
ORDER BY 'Count' desc