Hi There,
I have a requirement where i have to update all stored procedures in my server which has a constant variable i have to updated all my stored procedures
based on that constant variable using a single query/stored procedure.
can any one please anyone help me with this requirement.
Updating a variable in stored procedure using query
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Pankaj PandeyRank #642 · 3.7K reputationPosted Jun 3, 2013, 5:57 AM EDT
try below query
select replace(replace(definition,'create','alter'),'x','y') from sys.sql_modules where definition like'% procedure %' or definition like'% proc %'
it will show a list of definition of all stored procedures.
Copy all rows and paste on query editor and click on run, it will alter all your procedures in one shot.
Pankaj PandeyRank #642 · 3.7K reputationPosted Jun 3, 2013, 5:19 AM EDT
Can you explain your need with example, i had worked with dynamically creation of SPs so may be i will help you, but after getting completely what your need...so explain it with an example.
midhun b20 reputationPosted Jun 3, 2013, 5:26 AM EDT
and i have a static variable say "x".
now i want to replace that "x" in all my stored procedures with say "y".
with a single query / stored procedure.
this is what my requirement
midhun b20 reputationPosted Jun 4, 2013, 3:35 AM EDT