简体   繁体   中英

SQL Server objects in database

Well, I haven't found exact what I need in similar questions...

What is the quickest way for renaming object/s in DB?

Bulk renaming while keeping dependencies?

Any tips are welcome.

With sp_rename you can rename object in SQL Server but you are right, they will break dependencies, so that is not the way to go...

There are several (non-free) tools that can do this, and since they are on the market, I think they are there to solve a problem you can't solve yourself (instead of getting a database script and use Rename all ).

A tool that you could use is RedGate SQL Refactor .

You can of course use the sp_rename procedure to rename an object, however you'll need to find all objects that an object depends on, and all objects that depend on an object and change them to reflect the changes. You also need to change code of all external applications, if any that access that table.

If you want to rename stored procedure or a view the sp_rename is not advisable.

To rename a view

While you can use sp_rename to change the name of the view, we recommend that you delete the existing view and then re-create it with the new name.

The quickest way to rename an object without breaking dependencies is to use the third party tool. One of them is ApexSQL Refactor. You can find the whole procedure for renaming any object in the article: SQL database refactoring techniques – Rename method

Disclaimer: I work for ApexSQL as a Support Engineer

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM