Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

T-SQL refactoring

Keeping your SQL objects’ naming rules during furious development is hard. New levels of information are added continuously, entities are being splitted, then joined together again, entities are often renamed several times just because you have better name for them etc. For me, renaming is heart of T-SQL refactoring. But whenever you need to rename stored procedure which is referenced by many others, you have no built-in options how to do that. If you are in Visual Studio .NET and have ReSharper installed, it’s piece of cake. You just click rename, and it’s safely done throughout your solution.

You have one painful “workaround” in T-SQL (as far as I know) – to script all dependencies and perform careful search and replace operation and re-create all affected objects. I personally hated that because when
I was refactoring I wanted to think only about proper new names, not about anything else. But if you’re renaming frequent word which is used in not only in object name (but in column names etc.), you’re forced to walk through hundreds of lines and thinking If I should rename this or that.

On my current project, we started to use SQL Prompt SSMS add-in many months ago but I discovered it’s great value for T-SQL refactoring yesterday. It provides feature which is invaluable for described refactoring scenarios. This features is called “Smart Rename” and provides consistent renaming of SQL object even with renaming it in all dependencies.

Saved me hours this week.

Comments

Posted by Anonymous on 29 July 2011

Pingback from  Dew Drop – July 29, 2011 | Alvin Ashcraft's Morning Dew

Leave a Comment

Please register or log in to leave a comment.