Find all stored procedures that reference a specific column in some table

前端 未结 9 1877
广开言路
广开言路 2021-01-30 16:01

I have a value in a table that was changed unexpectedly. The column in question is CreatedDate: this is set when my item is created, but it\'s being changed by a st

9条回答
  •  故里飘歌
    2021-01-30 16:48

    -- Search in All Objects

    SELECT OBJECT_NAME(OBJECT_ID),
    definition
    FROM sys.sql_modules
    WHERE definition LIKE '%' + 'ColumnName' + '%'
    GO
    

    -- Search in Stored Procedure Only

    SELECT DISTINCT OBJECT_NAME(OBJECT_ID)
    FROM sys.Procedures
    WHERE object_definition(OBJECT_ID) LIKE '%' + 'ColumnName' + '%'
    GO
    

提交回复
热议问题