Searching in SQL Management Studio 2005

前端 未结 5 1483
逝去的感伤
逝去的感伤 2021-01-16 09:11

Is there a way to search for text within stored procedures? For example I want to find out if a particular table is being referenced by any stored procedure.

5条回答
  •  臣服心动
    2021-01-16 09:37

    Use:

    SELECT OBJECT_NAME(m.object_id), m.*
      FROM SYS.SQL_MODULES m
     WHERE m.definition like N'%text_youre_looking_for%'
    

    SYSCOMMENTS and INFORMATION_SCHEMA.routines have NVARCHAR(4000) columns. So if "text_youre_looking_for" is used at position 3998, it won't be found. SYSCOMMENTS does have multiple lines, but INFORMATION_SCHEMA.routines truncates.

提交回复
热议问题