Thursday, 15 January 2015

tSQLt FakeTable fails with error "cannot be renamed because the object participates in enforced dependencies"

Table is probably included as part of some "schema binded" view. Use attached script to temporary remove schema binding.

Error:
"[Test] failed: (Error) A .NET Framework error occurred during execution of user-defined routine or aggregate "SuppressOutput":
System.Data.SqlClient.SqlException: Object '[dbo].[SomeTable]' cannot be renamed because the object participates in enforced dependencies."


Source on GIT

1 comment:

  1. This is beautiful, thank you!

    I have adapted this to make it work on objects that are not in the dbo schema, and to replace only the first occurrence of CREATE and WITH SCHEMABINDING in the object definition

    See https://gist.github.com/DaveBoltman/2ad19779ccd5f95dd4a7a5d47fe914cb

    ReplyDelete