SQLServer2005 批量查詢自定義對(duì)象腳本

使用系統(tǒng)函數(shù)object_definition和系統(tǒng)表 sysobjects 就可以了

object_definition的官方參考
http://msdn.microsoft.com/zh-cn/library/ms176090.aspx

以下代碼可以批量查看或者導(dǎo)出視圖、存儲(chǔ)過(guò)程、觸發(fā)器和函數(shù)的腳本
代碼如下:
select name , xtype , object_definition (id ) from sysobjects
where xtype in (‘V’ , ‘P’ , ‘TR’ , ‘IF’ , ‘TF’ , ‘FN’ )
order by xtype , name

和上面代碼等價(jià)的可以用 sys .sql_modules系統(tǒng)表代替 object_definition函數(shù)
代碼如下:
select b. name , b. xtype , a . definition from sys .sql_modules a , sys .sysobjects b
where a . object_id = b. id
order by b. xtype

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點(diǎn)贊5 分享
站長(zhǎng)的頭像-小浪學(xué)習(xí)網(wǎng)月度會(huì)員