We've started work on implementing some code formatting fucntionality and we're now able to format select, update, insert and delete statements (including joins, or & and clauses).
It's actually more complex than it appears at first because we have to parse the entire document, searching out for these keywords and then decide what formatting rules to apply to any document space before and after the keywords (including indentation amounts).
What we've got so far seems to work pretty well and it takes about 10 seconds to format 3000 lines of T-SQL code - hopefully you won't have written too many scripts that are that long.
We aren't yet dealing with nested statements or with T-SQL code that is bounded by brackets as this involves some additional complexity. But we'll be starting on this next.
The other thing we'll need to work on is providing some options to allow users to define what rules to apply to formatting. For now with gone with the following simple formatting structure shown below.
At this point, if you have any preferences regarding the formatting let us know and we'll include options to suit your preferences (e.g. commas should start on a new line, and statements should appear at the end of a line rather than the start, etc.)
select
col1,
col2,
col3
from
table1
inner join table2 on table2.col1 = table1.col2
where
col1 = 22
and col2 > 35
or col3 = 45
--columns appear on a new line and indented
--from statements appear on a new line and in-line with the preceding select statement
--tables appear on a new line and indented
--join statements appear on a new line and in-line with the previous line
--where statements appear on a new line and in-line with the preceding select statement
SQLDBcontrol Support
support@sqldbcontrol.com