Formatting SQL statements, for improving code readability, and maintainability when the SQL statement is changed , or when fields are added, is one of the tedious job I need to do during development .
SQL Server still does not have any formatting option - to make the above statement look better . Hence, I pasted team as it is , even knowing that Stringbuilder would have done justice , and maintaining the SQL statement shall be a little difficult compare to the formatted statement.
Later, while searching for a quick solution to the above, I came across SQL Pretty Printer. On using it, I found it an amazing tool, which has the following features.
- Formats SQL statements
- Beautifies SQL statements, alomg with customizable templates.
- Converts SQL to various language formats, C#, VB, HTML
- Converts C#, VB, PHP code to SQL; I have only tested with C#, and have seen it working
- SQL Re-factoring / Renaming of Tables and Columns .
The short video below explains the functionalities of the software.
The software comes in three versions ; namely desktop , SQL Server Addin and Visual Studio Addin.
I have used the Desktop version, and found it very handy and useful tool, for formatting SQL statements and converting them to relevant programming language syntax.
My Wish List :
While SQL Pretty Printer does as promised, I have prepared a small wish list :
- Conversion of SQL to parameterized queries.
- Conversion of SQL to LINQ – converting old SQL statements shall help developers to use LINQ and its functionalties.