Expand Wildcards
Published 15 May 2013
You can use Expand Wildcards to expand SELECT
* and SELECT table.*
statements so that they list all of the columns that exist in the referenced tables.
SQL Refactor takes USE database
statements into account to ensure that the correct columns are identified.
For example:
Would become:
To do this:
- Open the source script in a SQL Server Management Studio query editor.
Ensure you are connected to the SQL Server and database that contains the objects referenced in the
SELECT
statements.If the code contains
USE database
statements, SQL Refactor will change the connection as appropriate.- If required, select the code that contains the
SELECT
statements that you want to expand.
If you do not select any code, allSELECT
statements in the script are expanded. - On the SQL Refactor menu, click Expand Wildcards.
A progress dialog box is displayed. SQL Refactor connects to the SQL Server to expand all SELECT *
and SELECT table.*
statements in the code that you selected.
You can undo the changes to the script using the standard SQL Server Management Studio Undo features.
To keep the changes, save the script in the usual way.
If any wildcard characters could not be expanded, for example because the referenced table does not exist, an error dialog box is displayed and the wildcard characters are underlined in red in the query editor. To see error details for an individual wildcard character, move your mouse pointer to the character in the query editor. For example: