--遍历服务器中所有数据库名称
select a.name
from master..sysdatabases a
where a.dbid>=7
------------------------------------------------------------------------------------------------
--遍历数据库中的所有存储过程,并获得其参数个数、类型、长度
select
c.[name] sp_name, --存储过程名称
a.[name] pa_name, --参数名称
b.[name] pa_type, --参数类型
a.[length] pa_len --参数长度
from
syscolumns a , systypes b , sysobjects c
where
a.xtype=b.xtype and a.id=c.id
and c.xtype='p' and c.category=0
order by
sp_name
--c.category=0 也可改为c.status>=0 表示用户定义的储存过程
--category:用于发布、约束和标识
--status:保留,内部使用。Base_schema_ver统计的版本号
------------------------------------------------------------------------------------------------
--遍历数据库中的所有触发器名称
select a.name as tr_name
from sysobjects a
where a.xtype='tr' and a.category=0
------------------------------------------------------------------------------------------------
--遍历数据库中的所有函数,并获得其参数个数、类型、长度
select
f_name=c.[name], --函数名称
pa_name=case a.[name] when '' then 'returns' else a.[name] end, --参数名称
pa_type=b.[name], --参数类型
pa_len=a.[length] --参数长度
from
syscolumns a , systypes b , sysobjects c
where
a.xtype=b.xtype and a.id=c.id
and c.xtype in (N'FN', N'IF', N'TF') and c.category=0
order by
f_name