当前在线人数11683
首页 - 分类讨论区 - 电脑网络 - 数据库版 -阅读文章
未名交友
[更多]
[更多]
文章阅读:Re: Need help on finding dependency objects
[同主题阅读] [版面: 数据库] [作者:mirthcyy] , 2007年08月08日10:51:43
mirthcyy
进入未名形象秀
我的博客
[上篇] [下篇] [同主题上篇] [同主题下篇]

发信人: mirthcyy (百无聊赖), 信区: Database
标  题: Re: Need help on finding dependency objects
发信站: BBS 未名空间站 (Wed Aug  8 10:51:43 2007)

Try to use sysdepends if you can.

If not, you could use sp_helptext like the below if you try to find the
depend object of a obsolete table or procedure in whatever database you want
to search:


CREATE TABLE #tmpObjResult(ObjText nvarchar(1000))
DECLARE @ObjName nvarchar(100)

DECLARE curObject CURSOR LOCAL READ_ONLY FOR
    Select s.name from sysobjects s
    where s.xtype<>'PK' AND s.xtype<>'F' AND s.xtype<>'IT' AND s.xtype<>'D'
AND s.xtype<>'C' AND s.xtype<>'U' AND s.xtype<>'S' AND s.xtype<>'UQ' AND s.
xtype<>'SQ'
    order by s.name
   
OPEN curObject

FETCH NEXT FROM curObject INTO @ObjName
WHILE (@@FETCH_STATUS = 0)
BEGIN
    TRUNCATE TABLE #tmpObjResult

    INSERT INTO #tmpObjResult
    EXECUTE sp_helptext @ObjName
   
    IF EXISTS (SELECT 'X' FROM #tmpObjResult WHERE ObjText like '%obsolete
table or procedure%')
    BEGIN
        PRINT '[obsolete table or procedure] object is used in '[email protected]
    END

    FETCH NEXT FROM curObject INTO @ObjName
END

DROP TABLE #tmpObjResult

--
※ 修改:·mirthcyy 於 Aug  8 10:52:40 2007 修改本文·[FROM: 66.219.]

[上篇] [下篇] [同主题上篇] [同主题下篇]
[转寄] [转贴] [回信给作者] [修改文章] [删除文章] [同主题阅读] [从此处展开] [返回版面] [快速返回] [收藏] [举报]
 
回复文章
标题:
内 容:

未名交友
将您的链接放在这儿

友情链接


 

Site Map - Contact Us - Terms and Conditions - Privacy Policy

版权所有,未名空间(mitbbs.com),since 1996