Search code examples
sql-servervisual-studiostored-proceduresrenaming

How should I rename many Stored Procedures without breaking stuff?


My database has had several successive maintainers over the years and any naming guidelines that may have once been in place have been ignored.

I'd like to rename the stored procedures to a consistent format. Obviously I can rename them from within SQL Server Management Studio, but this will not then update the calls made in the website code behind (C#/ASP.NET).

Is there anything I can do to ensure all calls get updated to the new names, short of searching for every single old procedure name in the code? Does Visual Studio have the ability to refactor such stored procedure names?

NB I do not believe my question to be a duplicate of this question as the latter is solely about renaming within the database.


Solution

  • You could make the change in stages:

    1. Copy of the stored procedures to the new stored procedures under their new name.
    2. Alter the old stored procedures to call the new ones.
    3. Add logging to the old stored procedures when you've changed all the code in the website.
    4. After a while when you're not seeing any calls to the old stored procedures and you're happy you've found all the calls in the web site, you can remove the old stored procedures and logging.