How to Format SQL query?
While working on SQL queries especially when one is dealing is large lines of SQL code , in that case formatted and refracted query is a live savior. In this blog I’II provide you with the solution which I found quite useful.
#Formatting SQL query using SSMS
This is for the guys who regularly have to deal with the queries. There is no built in formatting in SSMS (SQL Server Management Studio) although Ctrl + Shift + Q will give you a Query Designer window from which you can copy formatted query but there are plugins available that will integrate with SSMS. There are a million others out there but not all of them that do plug into management studio, but the one I know of and it works very well is Apex SQL Refactor. It is a free plugin. Integrates with SSMS. Downside is that it is an all or nothing process. It does not refactor as you type. For complete Installation Guide of Apex SQL Refactor, you may refer this.
#Formatting SQL query using Online Tool
This is one of the quick solution if you don’t have any plugin or you don’t want to as you may not have to deal more with SQL queries, there are tools that will do formatting for you. Again guys there are many online free tools available that you can use to format your large queries. One of my favorite is SQL-Format because apart from formatting it will give you many option, desktop version for this is also available but I prefer to better save my PC storage and do it online.