How to count total number of stored procedure and tables in SQL Server 2008

后端 未结 7 1548
刺人心
刺人心 2020-12-24 06:40

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

7条回答
  •  天命终不由人
    2020-12-24 07:00

    This will give you the count of tables and stored procedures.

    SELECT 
        CASE TYPE 
            WHEN 'U' 
                THEN 'User Defined Tables' 
            WHEN 'S'
                THEN 'System Tables'
            WHEN 'IT'
                THEN 'Internal Tables'
            WHEN 'P'
                THEN 'Stored Procedures'
            WHEN 'PC'
                THEN 'CLR Stored Procedures'
            WHEN 'X'
                THEN 'Extended Stored Procedures'
        END, 
        COUNT(*)     
    FROM SYS.OBJECTS
    WHERE TYPE IN ('U', 'P', 'PC', 'S', 'IT', 'X')
    GROUP BY TYPE
    

    You can find in sys.objects all types of objects in the database. You will have to run this query on each of your databases to see the count of objects.

    You can find all information about what is stored in sys.objects here.

提交回复
热议问题