Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in

The Voice of the DBA

Steve Jones is the editor of and visits a wide variety of data related topics in his daily editorial. Steve has spent years working as a DBA and general purpose Windows administrator, primarily working with SQL Server since it was ported from Sybase in 1990. You can follow Steve on Twitter at

Quick Tips–SQL Prompt Custom Aliases

I love SQL Prompt, and think it’s a great productivity tool. Even before I worked at Red Gate, I love the tool and had a copy before Red Gate bought the technology from the original developer. Recently I’ve run into a few people that weren’t aware of some of the ways in which it can help you. This is a quick look at one of the ways I use SQL Prompt.

Custom Aliases

SQL Prompt can automatically create aliases for tables. However, as I’ve worked on different systems, I’ve often found that development teams like to use specific aliases consistently to ensure that everyone can easily read the code and understand which tables are being queried.

Suppose I decide that I have these tables:

  • Product
  • Product Details
  • Orders
  • OrderDetails

I often use these tables in queries in my system, and I want to have consistent aliases. Right now, I could have these two queries with the default SQL Prompt alias settings:


Note that the Orders table has “O” as an alias in the first query, but “O2” as an alias in the second query. This isn’t an issue when I’m writing a query, but when I revisit this code in a month or two and add an enhancement, it can be tricky.

What I’d like to do is ensure I had consistent aliases for my tables, so that every developer always knows that “o” is Orders and “od” is OrderDetails. I want these aliases

  • Product – P
  • Product Details – PD
  • Orders – O
  • OrderDetails – OD

I can do that in SQL Prompt with custom aliases. Let me go back to the Options dialog and select Aliases.


I’ve already added an item in the Custom aliases section for the product table. However I can click New (highlighted above) and I’ll get a little dialog.


I repeat this process for each table, and soon I have all four entered.


Now I can rewrite my query. I start typing each table, and once it’s highlighted, click “tab”. When I get done, I have:


A quick way to ensure that all of your tables are consistently aliased, no matter in which order you type things.


Filed under: Blog Tagged: QuickTips, Red Gate, SQL Prompt, syndicated


Leave a comment on the original post [, opens in a new window]

Loading comments...