I got a tweet after my SQL Prompt formatting piece that said a user would be interested in upgrading from v5 if “as ‘Alias’” was transformed into “’Alias’ = “.
Well, in v7.3, this is in there, and I didn’t realize it. You can clearly see this in the formatting actions options, which is a place I didn’t think to look.
Does this work? It sure does. Let’s examine a query you might get from a VCS or a colleague. Suppose you’re working in the new WideWorldImporters database.
You prefer to see the actual columns returned in the result set at the front of the query, with an alias = format. That’s what I prefer as well, and so I want to have the column list shown as:
PrimaryContactFullName = p.FullName,
PrimaryContactPreferredName = p.PreferredName
A quick CTRL+K, Y and I see this.
My aliases have moved.
This is a great feature for those of you that need consistent formatting. There are other alias options if you prefer the alias at the end.
Update: I originally had this as single quoted aliases, but as pointed out, that format is deprecated, so I wouldn’t use it.
And if you want to change this back, you can have a second formatting preference that you choose to reformat code before sending it back to someone else.
Give SQL Prompt a try today.
Filed under: Blog Tagged: Redgate, SQL Prompt, syndicated