Requiring AS keyword
adam_hafner
Posts: 85 Silver 2
in SQL Prompt
I have queries that have table aliases for the join and I want to use SQL prompt to reformat the queries to add the `AS` keyword between the table name and the table alias.
ie SELECT * from Table1 t1 join Table2 t2 ON t1.ID = t2.ID;
should become
SELECT * from Table1 AS t1 join Table2 AS t2 ON t1.ID = t2.ID;
How is that accomplished? I already have it setup so that if I type out the query it will automatically add `AS` but this doesn't have any affect if I have existing queries where `AS` is not used.
Thanks in advance!
ie SELECT * from Table1 t1 join Table2 t2 ON t1.ID = t2.ID;
should become
SELECT * from Table1 AS t1 join Table2 AS t2 ON t1.ID = t2.ID;
How is that accomplished? I already have it setup so that if I type out the query it will automatically add `AS` but this doesn't have any affect if I have existing queries where `AS` is not used.
Thanks in advance!
Tagged:
Best Answers
-
Jon_Kirkwood Posts: 423 Silver 5
Hi @adam_hafner
Thank you for reaching out on the Redgate forums regarding your SQL Compare formatting question.
I believe this may be a setting in SQL Prompt that can be used to add or remove the AS keyword when you format your code.
This is found in the menu SQL Prompt > Options and then Format > Styles > Add/remove AS keyword on alias definition for tables and views
Setting this to Add will format your code as per your example provided
Does this help with your inquiry?
Jon Kirkwood | Technical Support Engineer | Redgate Software -
adam_hafner Posts: 85 Silver 2@Jon_Kirkwood thanks for the response. That answered my question. I think I overlooked it because I thought it was already enabled. As you can see from the screenshot below the radio button looks active but the checkbox isn't checked. Could you have your team correct it so that it appears like the `Add/remove square brackets` when it isn't checked so that the radio buttons are disabled? It's not a huge thing, but would make it look consistent.
Thanks again for your help!
--Adam