brenkdar
brenkdar

Reputation: 190

Force rename table column name (case spelling)

We want to rename old upper-case fieldnames in our mssql db to "Pascal-Case".

Our problem is, there are a lot of dependencies on those columns.

For example:

sp_RENAME 'Object.OBJECTID' , 'ObjectID', 'COLUMN'

When executing the above SQL the following error is returned:

Object 'Object.OBJECTID' cannot be renamed because the object participates in enforced dependencies.

Because we are only change the character case, we do not really break deps. Is there a way to force this operation?

Upvotes: 1

Views: 1652

Answers (1)

Vahid Farahmandian
Vahid Farahmandian

Reputation: 6568

You have two choices to solve this problem:

Manual Method

  1. Use SQL Server Management Studio, View dependencies for the object you want to rename
  2. Update the DDL script for the dependent object with the new name of the renamed object
  3. Repeat steps #1 and #2 for all dependent objects, individually
  4. If you want to rename more than 1 object, repeat the steps 1 through 3

Automatic Method

You can simply use third party applications such as ApexSQL and use it's Safe Rename feature.(Watch the tutorial video here). You can also use RedGate's Smart Rename fetaure too.(Read more here)

Upvotes: 1

Related Questions