How to format Microsoft Dynamics GP SQL Stored Procedures
If you have, you would have noticed that they are extremely difficult to read. This is because comments and formatting white space are removed by Dynamics Utilities when it creates the stored procedures. This step was taken to improve performance of the resulting code, but has the side effect of making the code impossible to read.
In the past, when I have needed to analyse code in a stored procedure, I have manually formatted the code as I read it so I can see the levels of indentation and individual commands.
A little while ago, my friend Steve Gray talked about Formatting SQL. In his post he mentioned the free Format SQL site from Redgate (the people behind the SQL Prompt tool). I had heard of SQL Prompt before, but did not require all the features it offered and did not want to buy anything. I also found that the free Format SQL site did not work well when pasting in scripts via the clipboard.
I just wanted a free online tool to format cut and pasted text from a SQL stored procedure so I can read it.
So today, I used that wonderful invention.... an internet search engine, and found a number of free tools that work well:
In no particular order:
- T-SQL Tidy (http://www.tsqltidy.com/)
- Instant SQL Formatter (http://www.dpriver.com/pp/sqlformat.htm)
- Poor SQL (http://poorsql.com/)
17-Jan-2013: Just a follow up comment. Poor SQL is my preferred option, but mainly because it offers a free plug-in for SQL Server Management Studio and Visual Studio.