Define custom alias conditions

When you create a custom alias, you define the criteria in the Condition column. A condition specifies when an alias is applied to an identifier, such as a table, view, table-valued function, or synonym, that you insert into a SQL document from the suggestion list.

For a condition to apply, its criteria must be fully satisfied. If an identifier meets the condition, the Studio generates the alias based on the corresponding rule from the Action column.

Note

  • Each element in the condition must be enclosed in angle brackets < >.

  • Conditions are case-insensitive. You can define them in lowercase or uppercase, and they will apply regardless of the case used in the identifier.

Condition masks overview

Condition mask Explanation
<product> Matches an object name that equals product.
<*product> Matches any object name that ends with product.
<product*> Matches any object name that starts with product.
<*product*> Matches any object name that includes product.
<*> Matches any valid object name.
<schema>.<product> Matches an object name that equals product and is prefixed with schema.
<schema*>.<product*> Matches any object name that starts with product and has a prefix that starts with schema.
<database>.<schema>.<product> Matches an object name that equals product and is prefixed with database and schema.

Case 1: Alias for an object regardless of prefixes

To assign a custom alias (for example, NewAlias) to a database object (such as the Employee table) regardless of its server, schema, or database, define the condition without prefixes.

Generate an alias for the database object regardless of prefixes

This rule applies to any object named Employee, no matter which schema or database it belongs to.

Alias application example

When you select Employee from the suggestion list, the Studio inserts the alias NewAlias.

SELECT * FROM HumanResources.Employee NewAlias

SELECT * FROM Person.Employee NewAlias

SELECT * FROM dbo.Employee NewAlias

This ensures consistent aliasing of the Employee object across different databases and schemas.

Case 2: Alias for an object in a specific schema

To assign a custom alias (for example, NewAlias) specifically to the Employee table in the HumanResources schema, define the schema in the condition.

Generate an alias for the database object from a specific schema

Alias application example

This condition applies only to HumanResources.Employee. Objects with the same name in other schemas follow the default alias rules.

SELECT * FROM HumanResources.Employee NewAlias

SELECT * FROM Person.Employee e

SELECT * FROM dbo.Employee e

Case 3: Alias for an object with multiple prefixes

You can define up to three prefixes: server, database, and schema. A custom alias is generated only when all specified prefixes match exactly.

  • <server>.<database>.<schema>.<object> – three prefixes
  • <database>.<schema>.<object> – two prefixes
  • <schema>.<object> – one prefix

This ensures precise alias control when working with objects across multiple environments.

Generate an alias for the database object with multiple prefixes

Alias application example

The alias NewAlias is applied to the Address table only when the SQL statement includes all prefixes defined in the condition (server, database, and schema).

SELECT * FROM LinkToSQLServer2022.AdventureWorks2022.Person.Address NewAlias

If the server prefix (LinkToSQLServer2022) is missing, the alias isn’t applied.

SELECT * FROM AdventureWorks2022.Person.Address a

Case 4: Alias with a wildcard in the condition

You can use an asterisk (*) as a wildcard to match any sequence of characters in the condition. Place the wildcard anywhere within the condition and enclose it in angle brackets < >.

Use an asterisk (*) for any characters in the condition

Alias application example

The alias NewAlias is generated for objects matching Address in the Person schema from any server and database.

SELECT * FROM LinkToSQLServer2022.AdventureWorks2022.Person.Address NewAlias

SELECT * FROM LinkToSQLServer2022.AdventureWorks2019.Person.Address NewAlias

Case 5: Alias with a wildcard in the identifier

You can use an asterisk (*) inside an identifier to match partial names. This allows you to apply aliases to multiple objects that share a naming pattern.

Examples of valid conditions: <*name>, <na*me>, or <name*>.

Use an asterisk (*) in the identifier

Alias application example

The condition applies the alias NewAlias to all objects in the Person schema whose names start with Business.

SELECT * FROM Person.BusinessEntity NewAlias

SELECT * FROM Person.BusinessEntityAddress NewAlias

SELECT * FROM Person.BusinessEntityContact NewAlias