Share via


Refactor Database Code and Data

By using database refactoring, you can reduce the amount of effort required and the chance of errors when you make repetitive changes to your database project. For example, you might have to update hundreds of indexes, constraints, and procedures when you change the name of a table or the schema to which a table belongs. You can use the refactoring types in Visual Studio Premium to perform some of these repetitive tasks. In addition, you can create your own tools for additional types of refactoring or extend an existing type of refactoring to include different file types.

Common Tasks

In the following table, you can find descriptions of common tasks that refactoring can help you complete and links to more information about how refactoring can help you reach those goals.

Tasks

Supporting Content

Rename a database object: You can use refactoring to change all references to a database object throughout your database project. When you deploy the project, the refactoring log helps preserve the intent of your changes.

Rename all references to a server or database: You can use refactoring to automatically update the names of servers, databases, or SETVAR variables in cross-database references.

Move a database object to a different schema: You can use refactoring to move a database object to another schema and automatically update all references to that object throughout your database project. When you deploy the project, the refactoring log helps preserve the intent of your changes.

Fully qualify the names of database objects: You can use refactoring to fully qualify the names of database objects in your database project. By fully qualifying those names, you avoid ambiguous references.

Expand wildcard characters in SELECT statements: You can use refactoring to expand wildcard characters that are used in views, procedures, and scripts in your database project.

Get hands-on experience: You can become familiar with how to move database objects to different schemas, in addition to other types of refactoring, by following the walkthrough. You can also see how you can use refactoring as a part of your database development life cycle by completing the introductory walkthroughs.

Troubleshoot problems: You can learn more about how to troubleshoot common problems with database refactoring.

See Also

Concepts

Build and Deploy Databases to an Isolated Development Environment

Build and Deploy Databases to a Staging or Production Environment

Writing and Changing Database Code