Hello,
I need to create a backup copy of a group of stored procedures on the same database. Using TSQL I need to find all stored procedures that meet a criteria (WHERE pr.name = '%_SomeSuffix') and create that same procedure in the same database with a different name ('%_SomeSuffix_BAK).
Finding the stored procedures I need is easy
SELECT pr.name , pr.type_desc , pr.create_date , mod.definition FROM sys.procedures pr INNER JOIN sys.sql_modules mod ON pr.object_id = mod.object_id WHERE pr.Is_MS_Shipped = 0 AND pr.name LIKE '%_SomeSuffix'But I can't seem to find a way to then change the name of the procedure in mod.definition.
Is there some way to do this? Or do I need to export the stored procedures and do some string manipulation?
Thanks,
Nick