Define custom alias masks

The Action column controls how custom aliases are generated when a condition in the Condition column is met.

In the Action column, you can do the following:

  • Define a custom alias format: Specify the characters or structure that will be applied when an identifier is inserted from the suggestion list.

  • Exclude parts of an identifier: Omit specific parts of an identifier by enclosing them in square brackets ([ ]). Excluded parts aren’t used in alias generation.

  • Reference specific identifiers: Use placeholders to reference parts of a qualified name, such as server, database, schema, or object. The placeholders (<1>, <2>, and so on) are numbered from left to right based on the order of identifiers.

  • Disable alias generation: Select No Alias to prevent alias creation for objects that match the condition.

Alias masks overview

Action mask Explanation
Id<1> Adds the Id prefix to a generated alias.
<1><2> Generates an alias from the referenced identifiers.
<[Dept]1> Excludes Dept from a generated alias.

Case 1: Reference one identifier

To generate an alias from the only element in the condition, specify <1> in the Action column.

Use one element in the Action column

Alias application example

The alias is generated from the initials of the only identifier—ContactType.

SELECT * FROM Person.ContactType ct

Case 2: Add characters before or after an identifier

You can add characters before or after <1> to extend the generated alias.

Example 1: Add NewAlias after <1>

Add characters after <1>

Alias application example

NewAlias is added after the alias generated from ContactType.

SELECT * FROM Person.ContactType ctNewAlias

Example 2: Add NewAlias before <1>

Add characters before <1>

Alias application example

NewAlias is added before the alias generated from ContactType.

SELECT * FROM Person.ContactType NewAliasct

Case 3: Reference multiple identifiers

If a condition contains multiple elements (for example, a server, database, schema, and a table name), you can base the alias on one or more identifiers using placeholders.

Example 1: An alias based on the database name

To generate an alias from the database name (AdventureWorks2022), specify <2>, because the database is the second element in the condition.

Example with conditional numbering

Alias application example

The alias aw is generated from AdventureWorks2022 by applying the standard algorithm, which uses the uppercase letters of the PascalCase identifier.

SELECT * FROM LinkToSQLServer2022.AdventureWorks2022.Person.Address aw

Example 2: An alias based on the schema and table names

To generate an alias from the schema (Person) and the table (Address), specify <3> and <4>.

Example with conditional numbering

Alias application example

The alias pa is generated from the initials of the schema and table names.

SELECT * FROM LinkToSQLServer2022.AdventureWorks2022.Person.Address pa

Example 3: An alias based on four identifiers

If the condition is <*>.<*>.<*>.<*> and the alias mask is <1><2><3><4>, the alias is generated for all four identifiers by applying the standard algorithm.

Alias application example

SELECT * FROM LinkToSQLServer2022.AdventureWorks2022.Person.BusinessEntityAddress ltsawpbea

SELECT * FROM LinkToSQLServer2022.AdventureWorks2022.Sales.Customer ltsawsc

SELECT * FROM LinkToSQLServer2022.DWQueue.dbo.MessageQueue ltsddmq

Case 4: Exclude characters from an identifier

To exclude a part of an element defined in the Condition column, specify the element number in the alias mask and enclose the characters to exclude in square brackets [ ]. Place the alias mask in angle brackets < > in the Action column.

Example 1: Exclude characters from one identifier

In this example, Add is excluded from the fourth identifier (Address).

Example with excluded parts

Alias application example

The next character after the excluded part (r) is used as the alias.

SELECT * FROM LinkToSQLServer2022.AdventureWorks2022.Person.Address r

Example 2: Exclude characters from multiple identifiers

You can apply the same rule to multiple identifiers. In this example:

  • Adv is excluded from the second identifier (AdventureWorks2022).
  • Add is excluded from the fourth identifier (Address).

Example with adding conditions

Alias application example

When Adv is excluded from the second identifier (AdventureWorks2022), the alias is generated depending on the casing of characters that follows the exclusion.

If only lowercase characters follow (as in Adventureworks2022), the alias is generated from e.

SELECT * FROM LinkToSQLServer2022.Adventureworks2022.Person.Address er

If the identifier is AdventureWorks2022 (with an uppercase W), the alias is generated from the uppercase character instead.

SELECT * FROM LinkToSQLServer2022.AdventureWorks2022.Person.Address wr

Case 5: Combine referencing, excluding, and adding characters

You can create complex alias masks that combine referenced identifiers, excluded parts, and static values.

For example, you can:

  • Exclude Adv from the second identifier (AdventureWorks2022).
  • Exclude Add from the fourth identifier (Address).
  • Append the static value NewAlias to the result.

Example with static sets

Alias application example

The generated alias consists of wr (derived from the modified identifiers) followed by the static string NewAlias.

SELECT * FROM LinkToSQLServer2022.AdventureWorks2022.Person.Address wrNewAlias

Note

You can place static characters before, after, or between placeholders (<1>, <2>, and so on) to construct aliases in a consistent format.