Well, there are tons of third-party tools that promise this type of “safe renaming”, some for free and some not:
- ApexSQL has a free tool for this, as MWillemse wrote in his answer
- RedGate has a commercial tool called SQLPrompt , which also has secure renaming, but it is far from free.
- Microsoft has a visual studio add-in called SQL Server Data Tools (or SSDT in short version), as Dan Guzman wrote in his comment.
I must say that I have never tried any of these specific tools for this specific task, but I have some experience with SSDT and some RedGate products, and I consider them to be very good tools. I don't know anything about ApexSQL.
Another option is to try writing a sql script yourself. However, before you begin, you need to take a few things:
- Is it possible to access your table directly from outside the sql server? I mean, is it possible that some software executes the sql statement directly in this table? If so, you can break it when you rename this column, and no sql utility will help in this situation.
- Are your sql script writing skills really that good? I consider myself quite experienced with sql server, but I think writing a script like this is beyond my skills. It’s not that it was impossible for me, but it will probably take too much time and energy for something that I can get for free.
If you decide to write it yourself, there are several articles that can help you in this task:
First, the official Microsoft documentation sys.sql_expression_dependencies .
Secondly, an article titled Different Ways to Search for Dependencies of SQL Server Objects , written by 13 years of DBA experience, and, just as important, a related question on the StackExchange database admin website.
You could, of course, go in the safe way suggested by Gordon Linoff in your comment, or use synonyms such as destination data in your answer, but then you have to manually modify all the column dependencies manually, and from what I understand, this is what do you want to avoid.
Zohar peled
source share