Format SQL has started adding AS prior table object aliases

Thom_AThom_A Posts: 8 Bronze 1
edited June 3, 2019 11:38AM in SQL Prompt
Previously, SQL Prompt preserved the the omission of `AS` on object aliases, however, as of this morning it has started adding it. As a simple example If I had the SQL below:
SELECT MT.MyColumn AS Col<br>FROM MyTable MT<br>
It would change it to
SELECT MT.MyColumn AS Col<br>FROM MyTable AS MT;
Previously it would have simply added the semicolon, as I prefer to not use AS when aliasing an object (although i do for columns).

I haven't performed an update to Prompt this morning, and I'm running the latest version, so not sure why the behaviour has suddenly changed. I had a look at the style options, and there's nothing to enable (or disable) he  use of AS for object aliasing.

Any ideas why this has changed and how to revert the behaviour?

Best Answer

  • Alex BAlex B Posts: 1,131 Diamond 4
    Answer ✓
    Hi @Thom_A,

    Apologies, I've muddled it - the section I put before is for when you are typing. 

    The AS being included during formatting is handled by this section on the SQL Prompt menu > Options > Format >Styles menu:


    If you uncheck that it should stop adding this during formatting! 

    Kind regards,
    Alex
    Product Support Engineer | Redgate Software

    Have you visited our Help Center?

Answers

  • Alex BAlex B Posts: 1,131 Diamond 4
    Hi @Thom_A,

    I don't think there is a way for it to have just reverted.  The aliases are controlled by a section outside the "Styles" bit in "SQL Prompt Options > Inserted code > Aliases":


    Has the "Include AS in alias definition" checkbox been checked? 

    I believe this could have happened if you imported a .sqlpromptsettings file perhaps.

    Kind regards,
    Alex
    Product Support Engineer | Redgate Software

    Have you visited our Help Center?
  • Thom_AThom_A Posts: 8 Bronze 1
    Hi @Alex B  I don't make use of the Aliases page in the SQL Prompt Options:




  • Thom_AThom_A Posts: 8 Bronze 1
    edited June 4, 2019 2:21PM
    Thanks Alex. It was set to "Remove", however, I changed the option to Add, saved, and then changed it back and it fixed the problem. Guessing there was a setting error somewhere and rewriting the settings fixed it.

    Thanks.
Sign In or Register to comment.