Sorry for this shameless self-promotion, but in a vain attempt to attract more visitors to the T-SQL Tidy web site - I'm writting a small piece to advertise my site.
If you want to format / parse or tidy your T-SQL then visiting TSQL Tidy.com. Enter your y unformatted SQL into the box on screen then click 'Tidy', your SQL will then be transformed and beautified into well formatted SQL.