SQL Server 批量导出存储过程、视图和函数

邵彷 / 2023-08-19 / 原文

select a.name,a.[type],b.[definition] 
FROM sys.all_objects a,sys.sql_modules b 
where a.is_ms_shipped=0 and a.object_id = b.object_id and a.[type] in ('P','V','AF') 
order by a.[name] asc

当 type 为‘ P’ 时,为存储过程

当 type 为‘ V’ 时,为视图

当 type 为‘ AF’ 时,为函数