Quickest/Easiest way to use Search/Replace through all stored procedures

前端 未结 13 1074
萌比男神i
萌比男神i 2020-12-30 03:05

Actually, this is a 2 part question.

  1. Is it possible to use some sort of functionality to search through every stored procedure for a string and possibly rep

13条回答
  •  礼貌的吻别
    2020-12-30 03:22

    You can search the text of the stored procedure definitions using this

    SELECT 
      Name 
    FROM 
      sys.procedures 
    WHERE 
       OBJECT_DEFINITION(OBJECT_ID) LIKE '%YourSearchText%'
    

    Replacing is generally a bad idea, since you don't know the context of the text you'll find in the stored procedures. It probably is possible though via Powershell scripting.

    I prefer this solution to any others, since I'm comfortable writing queries- so finding text in all stored procs, that are in schema (x) and database (y) and names that start with (z) is quite an easy and intuitive query.

提交回复
热议问题