库里的东西太多了,在我印象中好像有个看related的东西吧.
目前用的sql2008.

解决方案 »

  1.   

    http://msdn.microsoft.com/zh-cn/library/ms345449(SQL.90).aspxSELECT * 
    FROM  sys.sql_dependencies 
    WHERE object_id = object_id('X')
       AND   referenced_major_id = object_id('Y')
       AND   referenced_minor_id = 0
       AND   class = 0;
      

  2.   

    sp_depends有点相似,但偏偏就是不能查函数!!!
      

  3.   

    select name from sys.objects b where b.type='fn'
    and exists(select 1 from sys.sql_modules a where a.object_id<>b.object_id 
    and charindex(b.name,a.definition)>0)
      

  4.   

    右击func -> 查看依赖关系
      

  5.   

    --这个是最省事的,最快速的
    select name from sys.objects b where b.type='fn'
        and exists(select 1 from sys.sql_modules a where a.object_id<>b.object_id 
        and charindex(b.name,a.definition)>0)--或者用游标一个一个存储过程的代码中去找
    --方法如下:
    --遍历所有函数和存储过程名
    create table txt(txt varchar(max))
    insert txt(txt) exec sp_helptext 存储过程名或函数名   --将脚本写入到表
    select * from txt where txt like '%函数名%'              --如果存在,那就记住这个是哪个存储过程或函数调用的
    --循环以上几步
      

  6.   

    Select * from sys.syscomments where  [text] like  '%fn%'