Count All Objects of a database

Source: https://blogs.msdn.microsoft.com/buckwoody/2007/09/24/script-of-the-day-count-all-objects-in-a-database/

SELECT  'Count' = COUNT(*) ,
        'Type' = CASE type
                   WHEN 'C' THEN 'CHECK constraints'
                   WHEN 'D' THEN 'Default or DEFAULT constraints'
                   WHEN 'F' THEN 'FOREIGN KEY constraints'
                   WHEN 'FN' THEN 'Scalar functions'
                   WHEN 'IF' THEN 'Inlined table-functions'
                   WHEN 'K' THEN 'PRIMARY KEY or UNIQUE constraints'
                   WHEN 'L' THEN 'Logs'
                   WHEN 'P' THEN 'Stored procedures'
                   WHEN 'R' THEN 'Rules'
                   WHEN 'RF' THEN 'Replication filter stored procedures'
                   WHEN 'S' THEN 'System tables'
                   WHEN 'TF' THEN 'Table functions'
                   WHEN 'TR' THEN 'Triggers'
                   WHEN 'U' THEN 'User tables'
                   WHEN 'V' THEN 'Views'
                   WHEN 'X' THEN 'Extended stored procedures'
                 END ,
        GETDATE()
FROM    sysobjects
GROUP BY Type
ORDER BY Type;

Comments

Popular posts from this blog

TSQL To Get All the Names of tables and Databases whose data have changed in last 24 Hours

To Get All the Names of tables and Databases their data have changed in last 24 Hours And Backup those databases

Apply paging in procedure