There are a variety of ways of formatting SQL and I’m sure there are addins for SQL Server Management Studio; however, I often work on clients servers and can’t just install anything I want.
Therefore, a web based alternative is favourite and SQLFormat is the best one I have come across so far.
To use, simple paste your code into the big box and click the Format SQL button:
You can even load a file should you wish.
I’m posting it here as a reminder to myself.