首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

关于数据库object的有关问题

2013-03-16 
关于数据库object的问题1.数据库的中的Views、store procedures、functions是保存在哪个表中?2.是否可以批量

关于数据库object的问题
1.数据库的中的Views、store procedures、functions是保存在哪个表中?
2.是否可以批量修改数据库视图或存储过程的内容,例如将其views和store procedures中所有有的'prtest'的字符用'Updtest'代替,请问怎样写?

谢谢!
[解决办法]
1.数据库的中的Views、store procedures、functions是保存在哪个表中?


 select name 'ObjectName',
        case xtype when 'V' then 'Views'
                   when 'P' then 'StoreProcedures'
                   when 'FN' then 'Functions' end 'ObjectType'
 from sys.sysobjects
 where xtype in('V','P','FN')


2.是否可以批量修改数据库视图或存储过程的内容,例如将其views和store procedures中所有有的'prtest'的字符用'Updtest'代替,请问怎样写?
--> 将views和store procedures产生为代码文件,打开代码文件,
    批量替换"prtest"为"Updtest",执行,更新.
[解决办法]
找到这些对象的ID,然后去SELECT * FROM sys.system_sql_modules这里找
[解决办法]
引用:
sorry,我是说Views、store procedures、functions的脚本是保存在哪个表中?


select a.name 'ObjectName',
       case a.xtype when 'V' then 'Views'
                    when 'P' then 'StoreProcedures'
                    when 'FN' then 'Functions' end 'ObjectType',
       b.definition 'Script'
 from sys.sysobjects a
 inner join sys.sql_modules b on a.id=b.[object_id]
 where a.xtype in('V','P','FN')

热点排行