A small free .Net and JS library (with demo UI, command-line bulk formatter, SSMS/VS add-in, notepad++ plugin, winmerge plugin, and demo webpage) for reformatting and coloring T-SQL code to the user's preferences.
IMHO the suggested behavior improves code readability. I quickly know what the statement is and what are clauses of that statement.
With the current formatter behavior (no indent for clauses), a subquery of a main query can be mistaken as a separate statement.
For example,
`
SELECT ItemID, ItemName
[tab] FROM dbo.Orders
[tab] WHERE OrderDate = '2019-05-01'
[tab] ORDER BY Amount DESC;
INSERT INTO #t
[tab] SELECT ItemID, ItemName
[tab] [tab] FROM dbo.Orders
[tab] [tab] WHERE OrderDate = '2019-05-01'
[tab] [tab] ORDER BY Amount DESC;
Current behavior:
SELECT ItemID, ItemName
FROM dbo.Orders
WHERE OrderDate = '2019-05-01'
ORDER BY Amount DESC;
INSERT INTO #t
SELECT ItemID, ItemName
FROM dbo.Orders
WHERE OrderDate = '2019-05-01'
ORDER BY Amount DESC;
Great tool!
Indent clauses of a statement.
IMHO the suggested behavior improves code readability. I quickly know what the statement is and what are clauses of that statement. With the current formatter behavior (no indent for clauses), a subquery of a main query can be mistaken as a separate statement.
For example,
` SELECT ItemID, ItemName [tab] FROM dbo.Orders [tab] WHERE OrderDate = '2019-05-01' [tab] ORDER BY Amount DESC;
INSERT INTO #t [tab] SELECT ItemID, ItemName [tab] [tab] FROM dbo.Orders [tab] [tab] WHERE OrderDate = '2019-05-01' [tab] [tab] ORDER BY Amount DESC;
Current behavior:
SELECT ItemID, ItemName FROM dbo.Orders WHERE OrderDate = '2019-05-01' ORDER BY Amount DESC;INSERT INTO #t SELECT ItemID, ItemName FROM dbo.Orders WHERE OrderDate = '2019-05-01' ORDER BY Amount DESC;
`
Big Thanks!!! Stan