TaoK / PoorMansTSqlFormatter

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.
http://www.architectshack.com/PoorMansTSqlFormatter.ashx
GNU Affero General Public License v3.0
969 stars 268 forks source link

Indent subsequent clauses of a statement #222

Open smatofu opened 5 years ago

smatofu commented 5 years ago

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