Expand Wildcard Characters in SELECT Statements

Expand Wildcard Characters in SELECT Statements

You can improve the design of your Transact-SQL code by expanding any wildcard characters in the SELECT statements in your database projects. For example, you can specify an unknown number of records by using SELECT * when you define a view or a stored procedure. However, the number of columns in the underlying table or view might change in a way that breaks consumers of your view or procedure.

Rather than searching for wildcard characters manually, you can automatically find any instances by using static code analysis. For more information, see Analyzing Database Code to Improve Code Quality. After you find all instances, you can automatically replace them with a fully qualified list of columns by using database refactoring. When you use refactoring, you can preview and then apply updates to database objects throughout a block of code or a database project.

When you use refactoring, you update only your database project, instead of a production database. By following this strategy, you gain all the benefits of database projects, which include version control and team development. When you deploy your changes, the refactoring log file can help preserve the intent of your changes to the database project.

For more information, see Build and Deploy Databases to an Isolated Development Environment.

NoteNote

In a team environment, you should run application and database unit tests before you deploy your changes to a production server. For more information, see Starting Team Database Development.

In the following table, you can find descriptions of common tasks that support this scenario and links to more information about how you can successfully complete those tasks.

Task

Supporting Topics

Get hands-on experience: You can become familiar with how to move database objects to a different schema, in addition to other types of refactoring, by following the walkthrough.

Walkthrough: Apply Database Refactoring Techniques

Expand wildcard characters in SELECT statements: You can use refactoring to expand wildcard characters used in your database project. As part of the refactoring operation, you can preview the changes before you apply them.

How to: Expand Wildcard Characters in SELECT Statements

Undo a refactoring operation: If you decide that a refactoring operation needs to be reversed, you can undo that refactoring operation in the current session of Visual Studio.

How to: Undo a Database Refactoring Operation

Deploy database refactoring changes: After you refactor the database project, you must deploy those changes to a target database. Typically you will deploy your changes to your isolated development environment to test them before you check them in to version control.

How to: Deploy Database Refactoring Changes

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

Troubleshooting Refactoring Issues

Community Additions

ADD
Show:
© 2016 Microsoft