Search

Showing posts with label Rename all stored procedures in database. Show all posts
Showing posts with label Rename all stored procedures in database. Show all posts

Tuesday, October 4, 2011

Rename all stored procedures in database


Below is the query to rename all stored procedures with some a specific word as prefix.

SELECT 'EXEC sp_rename '+ ''''+s.NAME+ '.' + p.NAME+''','''+s.NAME+ '.' +'your_prefix'+p.NAME+'''' FROM SYS.PROCEDURES p ,SYS.SCHEMAS s WHERE p.schema_id = s.schema_id

Warning: Executing this command is dangerous because it may rename system stored procedures too. To avoid such disaster, don't forget to include WHERE condition.