How to use Aliases in ApexSQL Generate

Applies to
ApexSQL Generate

This article explains what the Alias feature is and what is it used for in ApexSQL Generate.


The Alias is a database connection with all the required connection info, saved as a single named instance. It can be reused in the project, thus reducing the time for setting up the connection parameters needed for project creation and certain generators.

Alias consists of:

  • Server name – named instance of the SQL server
  • Authentication type – Windows authentication or SQL Server authentication
  • Username and password – required in case of a SQL Server authentication
  • Database name

Aliases are saved on the application level, which means that an alias created once can be used in any project or generator at a later notice.

Upon the installation of ApexSQL Generate, in order to use the Alias connection, at least one alias must be created.

By clicking the Manage aliases button, the options for adding new, editing or deleting an existing alias are presented.

Adding a new alias

In the Add alias dialog, a name of the alias should be typed in. The default value is “New alias”.

Quick tip icon

Quick tip:

The application doesn’t allow two or more aliases using the same name. If an alias with the same name already exists, the name of the new alias will be accompanied with a suffix (1)

Editing an existing alias

After the alias is created and named, the connection options are set up. Upon the selection of the alias from the list, the connection options for that alias are shown, and can be edited on the spot.

When an SQL connection is used, username and password need to be entered, so that ApexSQL Generate can access the server by using those credentials.

Quick tip icon

Quick tip:

When using SQL Server authentication, be sure to check the Remember password option. The password is saved as encrypted, so that the credentials are safe from an unauthorized access

The Edit button allows renaming of the alias, but all other options remain the same.

Multiple aliases can be renamed and edited at once, and by pressing the OK button, all the changes are saved.

The Delete button removes selected aliases from the list of available aliases.

Usage of aliases in ApexSQL Generate

Aliases are used in the connection step, for the Table and the Query generator.

At the project creation step, two options for the connection to the desired database are presented:

  1. Database connection
  2. Alias connection

To connect using an alias, simply choose one from the list of created aliases and press the Connect button (or press the Enter key).

The SQL table or view generator populates the selected destination column by using a column with the same type from any database table or view as the source of data, so it needs the connection info to be able to read the data.

The SQL query generator uses a similar technique, but it has an option to execute the SQL query against the database, represented by the chosen connection and inserts the results into the destination column.

Table and Query generators can be set for any column, so the need for a connection information can be frequent, but also different each time. ApexSQL Generate does not have any limitations to the number of databases from which the data can be used as a source. That’s why it is recommended to use the alias connection, as it needs to be set up only once, and can be used for numerous times.

Top FAQ’s about Alias feature in ApexSQL Generate

Q: What level are alias set at – project, table, column etc

A: The aliases are saved on the application level, which means that once created, they can be used in any project or generator settings.

Q: Can I set one alias and use it across the whole project?

A: Yes, once created, each alias can be used on any place in the project where there is a need for a database connection details (initial connection at the project start, Table generator, Query generator)

Q: If my connection changes, can I change it once and update all uses of it?

A: Yes, when an alias is updated using Alias management dialog, the changes are synchronized across all usage places.

Q: Can I use an alias in other projects?

A: Yes, since the aliases are saved on the application level, they can be used in any open project.

Q: Can others in my team use my project with my aliases, can I use it on another computer?

A: No, the fact that aliases are saved on the application level limits the usage of aliases to a single computer. When a project is saved, only alias name is preserved in it, not the actual alias instance. To be able to use the saved project on another computer, an alias with the same name must be created in order to be recognized by the project. This is because the alias contains actual info about username and password, so in order to preserve the integrity of the user creating the project, that info is not saved.