统计数据库的表、存储过程、视图、触发器

来源:互联网 发布:网站排名优化软件 编辑:程序博客网 时间:2024/06/05 13:28
select 
    (
select count(*as 用户数据表 from  数据库名.dbo.sysobjects where xtype='u' and status>=0as 用户数据表,
    (
select count(*as 用户存储过程 from  数据库名.dbo.sysobjects where xtype='P' and status>=0as 用户存储过程,
    (
select count(*as 用户视图  from  数据库名.dbo.sysobjects where xtype='V' and status>=0as 用户视图,
    (
select count(*as 触发器 from  数据库名.dbo.sysobjects where xtype='TR' and status>=0as 触发器

系统存储过程:数据库信息

A. 返回有关单个数据库的信息
下面的示例显示有关 pubs 数据库的信息。

exec sp_helpdb pubs

B. 返回有关所有数据库的信息
下面的示例显示有关运行 Microsoft® SQL Server™ 的服务器上的所有数据库的信息。

exec sp_helpdb