Mass Renaming of Tables and Stored Procedures

前端 未结 3 955
悲哀的现实
悲哀的现实 2021-01-06 16:24

I need to rename all of my tables, stored procedures and obviously the code within each stored procedure that was referencing the old table names.

Why is the best w

3条回答
  •  伪装坚强ぢ
    2021-01-06 16:52

    I would use sp_rename for the tables.

    For everything else, I would script the database, do a search and replace on the text file, and then execute the script back to your database:

    In Management Studio, right click on the database name, then 'Tasks', then 'Generate Scripts'.

    Don't script all objects in the selected database, just stored procedures, synonyms, user defined functions and views.

    Also, make sure you set the following options: Script Drop, Script Object Level Permissions, Script Create.

    I realize this is a little tedious, and it depends how many objects we're talking about, and (of course), I would do this is in development first, but I've used this process before and it works well.

提交回复
热议问题