且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何计算 SQL Server 2008 中存储过程和表的总数

更新时间:2023-12-01 15:56:34

这将为您提供表和存储过程的数量.

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

您可以在sys.objects 中找到数据库中所有类型的对象.您必须在每个数据库上运行此查询才能查看对象数.

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.

您可以找到有关 sys.objects 中存储内容的所有信息 此处.

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