A subject I have ranted about from time to time (here on the blog of course, in private I rant about this at least once a day...) is code formatting. It is always a real pain to get some code from a user from the web (or someone else, closer to you) that is formatted in a way that makes it hard to read. Now there is a tool for you that is easy, and can be nicely integrated into Management Studio in a very natural manner.
The tool is Red Gate's "SQL Refactor" and the public CTP release finally arrived today. (This, by the way is one of the tools that I have been dying to tell you about.)
From this Red Gate forum post (which contains the download line), here is the list of features:
- SQL Lay Out reformats your T-SQL scripts. You can select this feature from the top level SQL Refactor menu. There are over 30 options to control this feature, these you can access from the top level SQL Refactor menu.
- Smart Rename renames functions, views, stored procedures and tables, and updates all the references to these renamed objects. You can select this feature from the context menu in Management Studio’s Object Explorer.
- Smart Rename parameters and columns renames parameters of stored procedures and functions, and columns of tables and views. You can select this feature from the context menu in Management Studio’s Object Explorer.
- Table Split splits a table into two tables, and automatically rewrites the referencing stored procedures, views, and so on. You can also use this refactoring to introduce referential integrity tables. You can select this feature from the context menu in Management Studio’s Object Explorer.
- Uppercase keywords turns keywords in your script or selection to uppercase.
- Summarize Script provides you with an overview of your script. By highlighting items in this overview you can see the corresponding statements highlighted in your script.
- Encapsulate as stored procedure turns your selection into a new stored procedure, and if requested, introduces a reference to it in your script.
- Expand wildcards expands SELECT * statements to include a full list of columns in the select part.
- Find unused variables and parameters shows you the variables and parameters in you script that are not used, or that are only assigned to.
- Qualify Object Names modifies the script so that all object names are qualified. You can select this feature from the top level SQL Refactor menu.
The features that I am very excited about are:
- SQL Lay Out Kind of obvious that this is one thing I have been dying for. It does a good job with those 30 options to making it look like the code that I am used to when I write code.)
- Uppercase keywords, mostly for when I am writing a book and this is required. I don't generally like uppercased keywords as it starts to remind me of COBOL (shudder.)
It is still a beta, and you will find some bugs, but from my initial testing it seems overall to be quite usable (though it does proclaim not to use it in production :)
A very nice touch is that they have a forum question to allow discussion on how much the final product should cost. They have set the price at $295 per user, but who knows. I know if they get enough people beating them up over it, they will change their minds. I remember when we all beat up on Microsoft for making some of the features of SQL Server available in Enterprise Edition only (like Report Builder.) They relented in many cases, and if they are open to discussion, they might be open to a change.
Crossposted to http://drsql.spaces.live.com