How to rename aliases

SQL Complete generates aliases automatically for tables, views, table-valued functions, and synonyms.

You can rename default aliases directly in the code. All references to the renamed aliases will be automatically replaced with the relevant ones.

To rename an alias:

1. In the SQL code editor, place the cursor over the alias you want to rename and use one of the following options:

  • Right-click the alias and select Rename.
  • Go to the SQL Complete menu and then select Rename.
  • Press F2.

The alias will be highlighted.

2. Enter a new name for the alias. As you type, a tooltip appears instructing you to Press F2 to preview changes or Enter/Tab to apply.

3. Optional: To display the preview dialog, press F2. In the Preview Changes - Rename dialog that opens, preview the code changes and click Apply to apply them.

4. To proceed without preview, press Enter/Tab to apply your changes in the code.

Note

In case the alias and the column name are the same, the renaming of the alias does not affect the column name.

Let’s take the following procedure as an example:

CREATE OR ALTER PROCEDURE Person.EmailAddressID 
  @EmailAddress VARCHAR(30) = '%'
AS
  DECLARE @EmailAddressList VARCHAR(30)
  SELECT
    email.EmailAddressID AS EmailID
  FROM Person.EmailAddress email
  WHERE email.EmailAddress LIKE @EmailAddress;
GO
EXECUTE Person.EmailAddressID @EmailAddress = 'adriana%'
GO

Try to rename the alias in the query using the built-in SSMS Find & Replace functionality. As you can see, the names of the procedure and its parameters have been changed as well.

Renaming aliases

Now, try to rename the alias in the query with the SQL Complete Refactoring feature. As you can see, the renaming of aliases does not cause the renaming of the procedure and its parameters.

Renaming aliases

Note

You can undo any action by pressing Ctrl+Z.

Example: Rename an alias in the SELECT query in the procedure code

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge SQL Complete for SQL Server.
All Features

All features

Get acquainted with the rich features and capabilities of the SQL Complete in less than 5 minutes.
Request a demo

Request a demo

If you consider employing the SQL Complete for your business, request a demo to see it in action.
Ready to start using dbForge SQL Complete for SQL Server?