Scott Kramer Scott Kramer - 1 year ago 118
SQL Question

sql 2005 force table rename that has dependencies

How do you force a rename???

Rename failed for Table 'dbo.x. (Microsoft.SqlServer.Smo)

For help, click:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

Object '[dbo].[x]' cannot be renamed because the object participates in enforced dependencies. (Microsoft SQL Server, Error: 15336)

For help, click:

Answer Source

Find the "enforced dependencies", then remove or disable them.

By "enforced dependencies", it means Schema binding, so you'll have to look specifically for that.

Here's a query to look for schema binding references to your object:

select as ObjName, as ReferencedObj
from sys.sql_dependencies d
join sys.objects o on o.object_id=d.object_id
join sys.objects r on r.object_id=d.referenced_major_id
where d.class=1
AND = @YourObjectName

As I noted in the comments, there is no way to FORCE-ibly override Schema Binding. When you use Schema Binding, you are explicitly saying "Do not let me or anyone else override this." The only way around Schema Binding is to undo it, and that's intentional.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download