Renaming Something Without Breaking Everything

Treat a request to rename database object identifiers as an interface change. The new name is easy to create, but existing callers may still depend on the old one.

Two blank wooden tags attached to the same small wooden box with plain cotton string.

Inventory the Name Before Changing It

Identify the exact database, schema, object type, and owner. Then find who calls it and why the rename is needed. A cosmetic improvement may not justify disruption to several applications.

DECLARE @ObjectName nvarchar(517) = N'dbo.YourTable';
SELECT object_id, SCHEMA_NAME(schema_id) AS schema_name,
       name, type_desc, create_date, modify_date
FROM sys.objects
WHERE object_id = OBJECT_ID(@ObjectName);

Save the current definition, permissions, and dependency findings before making the change. Keep a reversal plan that accounts for callers deployed at different times. Renaming the object back may not reverse every related application change.

Search Both Dependencies and Text

Catalog dependencies identify many persisted SQL references. Search module definitions as a second source of evidence. Neither method can see every query stored in application code, reports, jobs, or dynamically assembled strings.

DECLARE @ObjectName nvarchar(517) = N'dbo.YourTable';
SELECT OBJECT_SCHEMA_NAME(referencing_id) AS schema_name,
       OBJECT_NAME(referencing_id) AS referencing_object,
       referenced_schema_name, referenced_entity_name
FROM sys.sql_expression_dependencies
WHERE referenced_id = OBJECT_ID(@ObjectName);
SELECT OBJECT_SCHEMA_NAME(object_id) AS schema_name,
       OBJECT_NAME(object_id) AS module_name
FROM sys.sql_modules
WHERE CHARINDEX(N'YourTable', definition) > 0;

Text matches can include comments and unrelated names, so review them rather than replacing blindly. Encrypted modules and restricted metadata visibility create gaps. Record those gaps instead of reporting no dependencies.

Check cross-database callers and application owners separately. A local catalog cannot provide a complete inventory of external use. Runtime evidence can supplement the search when collection already exists or a focused capture is approved.

Know What Sp_Rename Leaves Behind

Renaming a table or column does not automatically rewrite every reference to its old name. Procedures, reports, and application statements can fail afterward. Review stored metadata as well as source text.

For procedures, views, functions, and triggers, sp_rename also leaves the original name in the module definition text. Microsoft recommends avoiding sp_rename for those module types. A reviewed create-and-migrate approach keeps the definition aligned with the intended name.

-- Run only in a fresh disposable test database.
CREATE TABLE dbo.RenameLabOld
(
    Id int PRIMARY KEY,
    Description nvarchar(50) NOT NULL
);
INSERT dbo.RenameLabOld VALUES (1, N'Example');
EXEC sys.sp_rename N'dbo.RenameLabOld', N'RenameLabNew', N'OBJECT';

This demonstrates a table rename using unique lab names. It does not update any caller for you. Test dependencies before applying an equivalent production change.

Use a Compatibility Name Where It Fits

For some table or procedure access paths, a synonym can keep an old name available while callers migrate. The old name must first be free. The synonym points to the new base object by name.

CREATE SYNONYM dbo.RenameLabOld FOR dbo.RenameLabNew;
SELECT Id, Description FROM dbo.RenameLabOld;
SELECT name, base_object_name FROM sys.synonyms
WHERE name = N'RenameLabOld';

This continues the disposable example in the same database. A synonym is not a universal compatibility layer. It does not rename columns, support every DDL operation, or work in schema-bound references.

Base-object existence and permission checks are deferred to runtime, so creation success proves little about the caller's access. Review grants on the synonym and the underlying object. Test using the actual application identity.

Deploy Callers in a Controlled Sequence

Update application queries, reports, jobs, and dependent modules to use the new name. Check whether cached metadata or generated code needs refresh. Use supported refresh procedures only where appropriate, after reviewing their effects.

Keep the compatibility name for an agreed migration period, with an owner and removal criteria. Monitor remaining use through suitable evidence. A temporary alias without an end condition becomes another permanent interface.

Test reads, writes, errors, and permissions through both intended paths while they coexist. A SELECT that succeeds under an administrator account is not sufficient. Some clients inspect object metadata before issuing their normal commands.

Verify the Contract After the Rename

Repeat dependency searches and compare application behavior with the pre-change baseline. Confirm that object definitions and operational scripts use the expected names. Keep unresolved external callers visible in the change record.

Only remove the compatibility name after the agreed callers have migrated and the observation period is meaningful. Include the removal in its own reviewed change. The goal is a clearer interface without surprising the people who depend on it.

A rename is not just a metadata edit, it is a migration of an interface.

This post was rewritten from scratch in September 2026. The original, published on 2014-01-08, was a short announcement about something that no longer exists. The address is the same, the subject is now something worth keeping.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.

Best Practices, Database, SQL Scripts, SQL Server
Previous Post
MySQL – Locate the Configuration File – my.ini or my.cnf on Windows Platform
Next Post
SQL SERVER – Auditors, Passwords and Exceptions – Notes from the Field #010

Related Posts

3 Comments. Leave new

  • I downloaded all the Apex tools and installed. My SQL Server management studio became literally unusable, sometimes I’d type and wait 3 minutes before I got control back. They were uninstalled and now I am able to work again.

    Reply
  • There were some issues ApexSQL add-ins are resolved but, we have never received a complaint regarding all of our tools.

    Please be free to contact us at support@apexsql.com and we will be glad to help you

    Reply
    • I’m not sure what else there is to discuss. Install the tools, SQL Server 2012 is unusable. Remove them, and it works.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.