

Notice the functions len and count.Īlso, it indents AND clauses in the WHERE clause. It doesn’t make function names uppercase. Sample query formatted by Poor Man's T-SQL inside Notepad++ This is how Poor Man’s T-SQL format our sample query in Notepad++. You can try its formatting options online too. It’s available for Notepad++, Visual Studio, SQL Server Management Studio and others. NET and JavaScript library to format your SQL queries. Poor Man’s T-SQL Formatter is a free and open source. Let’s see how these two tools format our sample query. SELECT ParentId AS, COUNT ( id ) FROM posts WHERE posttypeid = 2 AND LEN ( body ) 1 ORDER BY COUNT ( id ) DESC Let’s format the query to find StackOverflow posts with many “thank you” answers. I changed two lines and I ended up formatting thousand of lines. Things were worse with long store procedures. Sometimes I ended up messing with variables, parameters or any other thing inside my queries. But, it only worked for making keywords uppercase. I tried to use “Find and Replace” inside an editor. It means making keywords uppercase, aligning columns and arranging spaces.

Beforeīefore using Poor Man’s T-SQL Formatter and ApexSQL Refactor, I spent too much time formatting queries by hand. And, ApexSQL Refactor for Visual Studio and SQL Server Management Studio. Inside Notepad++, use Poor Man’s T-SQL Formatter.

These are two free tools to format SQL queries and store procedures.
#Sql formatter online tool code#
Instead of formatting SQL queries to follow code conventions by hand, you can use online tools or extensions inside Visual Studio, SQL Server Management Studio or any other text editor. Two free tools to format SQL queries #sql #productivity #showdevĭo you need to format your SQL queries? Are you doing it by hand? Stop! There is a better way!
