SQL 中怎么查询数据库中具有的表、存储过程、试图数目、总触发器数、作业数

时间:2023-03-09 19:50:26
SQL 中怎么查询数据库中具有的表、存储过程、试图数目、总触发器数、作业数

用户表:select count(*) 总表数 from sysobjects where xtype='u'

刚才那个是用户表,下面这个是系统表加用户表:

select count(*) 总表数 from sysobject s where xtype in('u','s')
总视图数:select count(*) 总视图数 from sysobjects where xtype='v'
总存储过程数:select count(*) 总存储过程数 from sysobjects where xtype='p'
总触发器数:select count(*) 总触发器数 from sysobjects where xtype='tr'
数据库作业: SELECT count(*) FROM msdb.dbo.sysjobs