考虑到安全因素,我们经常需要对数据库的存储过程(SP)和函数(Fun)进行备份
下面提供了一种简单的方式,
存储过程(SP)SQL代码如下:
select p.name as SpName,m.definition as SpText from sys.procedures p join sys.sql_modules m on p. object_id = m. object_id
Table函数(Fun)SQL代码如下:
select o.name,m.definition from sys.all_objects o join sys.sql_modules m on o. object_id = m. object_id where o.type in ( ' tf ' , ' if ' ) order by o.name
Value函数(Fun)SQL代码如下:
select o.name,m.definition from sys.all_objects o join sys.sql_modules m on o. object_id = m. object_id where o.type = ' fn ' order by o.name