Blog Post

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.

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating