Table Aliases for all tables

VSAVSA Posts: 1 New member
I would like to use the table name and the table alias name to be the exact same instead of using auto-generated alias like p, f, d, etc. 

I do see an option to override the default shortcode alias but it is tedious task to enter the table name one by one with the same name in the alias. 

Is there a way where I can choose the default behavior as table name and alias name should match? Now I have disabled the alias but would like to populate the alias name in the query. Out of 100+ tables, I need to override the alias name only for a few tables, and the rest of the tables should use the same name. 

Thanks

Answers

  • Hi @VSA

    Thanks for your question on this!

    Unfortunately there is not currently a feature within the SQL Prompt GUI that enables you to populate alias names for multiple tables at once. You can only apply aliases one by one via the SQL Prompt Aliases options. 

    The user defined aliases are stored in the RedGate_SqlPrompt_Engine_EngineOptions.xml file in %LocalAppData%\Red Gate\SQL Prompt 10​ within the XML field for <UserDefinedAliases> and you would need to generate the encoded XML to insert within that field.

    So for this example below:




    it is stored as:

      <UserDefinedAliases>&lt;UserDefinedAliases&gt;
      &lt;Count&gt;1&lt;/Count&gt;
      &lt;UserDefinedAlias&gt;
        &lt;ObjectName&gt;Facility&lt;/ObjectName&gt;
        &lt;Alias&gt;Fac&lt;/Alias&gt;
      &lt;/UserDefinedAlias&gt;
    &lt;/UserDefinedAliases&gt;</UserDefinedAliases>

    You can close SSMS, manually edit the XML directly to add another entry and then restart SSMS (just be sure to increase the count as well when you drop in another encoded XML alias chunk):

      <UserDefinedAliases>&lt;UserDefinedAliases&gt;  &lt;Count&gt;2&lt;/Count&gt;
      &lt;UserDefinedAlias&gt;
        &lt;ObjectName&gt;Facility&lt;/ObjectName&gt;
        &lt;Alias&gt;Fac&lt;/Alias&gt;
      &lt;/UserDefinedAlias&gt;
      &lt;UserDefinedAlias&gt;
        &lt;ObjectName&gt;abtest&lt;/ObjectName&gt;
        &lt;Alias&gt;abt&lt;/Alias&gt;
      &lt;/UserDefinedAlias&gt;
    &lt;/UserDefinedAliases&gt;</UserDefinedAliases>


    this would then show up as:




    But unfortunately we don't have a tool to do such a thing currently. 

    It would fall under a feature request and we recommend adding it to the uservoice forum https://redgate.uservoice.com/forums/94413-sql-prompt.


    Kind regards

    Dan Jary | Redgate Software
    Have you visited our Help Center?
Sign In or Register to comment.