Baldie47
Baldie47

Reputation: 1264

Replace text in several stored procedures

I have to replace text pointing to an object to point into another object for different stored procedures. I have to modify the text within them and they're several, so scripting them as alter and then changing the text is not ideal.

I was able to identify the SP I need to change via a query:

--Search in Stored Procedure Only
SELECT DISTINCT 
    OBJECT_NAME(OBJECT_ID), 
    OBJECT_DEFINITION(OBJECT_ID)
FROM sys.Procedures
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%' + 'stringToSearch' + '%';

GO

I'm struggling about how to do the replace of the text for them.

Any thoughts?

Upvotes: 0

Views: 834

Answers (1)

Mohsen yousefi
Mohsen yousefi

Reputation: 71

you can generate a script from your database (right click on your database--> tasks--> generate script--> select just your procedures) and then open it in the SSMS, then press cntrl+f, and then replace your specific text

Upvotes: 2

Related Questions