How do I find a stored procedure containing ?

后端 未结 20 2023
梦谈多话
梦谈多话 2020-11-28 17:21

I need to search a SQL server 2008 for stored procedures containing where maybe the name of a database field or variable name.

相关标签:
20条回答
  • 2020-11-28 17:53
    select * from sys.system_objects
    where name like '%cdc%'
    
    0 讨论(0)
  • 2020-11-28 17:55

    I tried above example but it was not showing more than 4000 characters then I modified it little bit and was able to get whole stored procedure definition. Please see the updated script below -

    SELECT SCHEMA_NAME(O.SCHEMA_ID) [SCHEMA_NAME], O.NAME, OBJECT_DEFINITION(OBJECT_ID) TEXT
    FROM   SYSCOMMENTS AS C
           INNER JOIN SYS.OBJECTS AS O ON C.ID = O.[OBJECT_ID]
           INNER JOIN SYS.SCHEMAS AS S ON O.SCHEMA_ID = S.SCHEMA_ID
    WHERE  OBJECT_DEFINITION(OBJECT_ID) LIKE '%FOO%'
    ORDER BY  SCHEMA_NAME(O.SCHEMA_ID), O.NAME
    
    0 讨论(0)
提交回复
热议问题