Start a new topic

SQL formatting improvements

[This topic is migrated from our old forums. The original author name has been removed]

The SQL query formatting facility is very handy but I do still find myself correcting a number of alignment issues manually, which on a large script can be a lot of edits and usually results in me editing seperately in vim. I was hoping we could have 2 changes to the formatting options, which would eliminate almost all corrections: 1. Indent the "ON" clause. When enabled, this ability would convert this: +        select *+ +        from sys.tables t+ +        join sys.columns c+ +        on t.object_id = c.object_id+ +          and c.name like 'audit_when'+ to this: +        select *+ +        from sys.tables t+ +        join sys.columns c+ +          on t.object_id = c.object_id+ +          and c.name like 'audit_when'+ 2. Allow "Alignment on Commas" to have the extra option "except inside IN operator". When enabled, this ability would convert this: +        select c.object_id+ +        , c.name+ +        , c.user_type_id+ +        , c.max_length+ +        from sys.columns c+ +        where c.name in ('audit_when'+ +                                        , 'audit_who')+ to this: +        select c.object_id+ +        , c.name+ +        , c.user_type_id+ +        , c.max_length+ +        from sys.columns c+ +        where c.name in ('audit_when', 'audit_who')+ I notice that the "Alignment on Commas" option is already ignored when inside brackets of t-sql functions like CHECKSUM, COALESCE, etc so I hope it should be simple to give the option to do the same for IN.

[This reply is migrated from our old forums.]

Re: SQL formatting improvements
Hi Vince, Thanks for the suggestions. We will not have the time to do anything with the SQL Formatter for 9.0, but I have registered your suggestions so we may have a look at them, along with others, later. Best Regards, Hans
[This reply is migrated from our old forums. The original author name has been removed]

Re: SQL formatting improvements
Thanks Roger, Another possible improvement to consider when the SQL Formatting does get an overhaul would be "Indent 1st list item", which would convert: +      select distinct top 100 1+ +      , 2+ +      , 3+ +      , 4+ +      , 5+ to: +      select distinct top 100+ +        1+ +      , 2+ +      , 3+ +      , 4+ +      , 5+

1 person likes this
[This reply is migrated from our old forums.]

Re: SQL formatting improvements
Hi Vince, I've registered that suggestion as well. Thanks, Hans