Hi there,
Got a problem – a database with CDC enabled was migrated onto a new server (by attaching all DB files I think).
As a result all CDC related objects were still existing in the database, but CDC was not enabled.
I could not enable CDC on the migrated database because the CDC schema already existed (from before migration).
Msg 22906, Level 16, State 1, Procedure sp_cdc_enable_db_internal, Line 49
The database 'xxxxx' cannot be enabled for Change Data Capture because a database user named 'cdc' or a schema named 'cdc' already exists in the current database. These objects are required exclusively by Change Data Capture. Drop or rename the user or schema and retry the operation.
So I deleted all tables, stored procs and functions from the CDC schema – well – at least I thought I did – so dropping the schema should be possible.
Msg 3729, Level 16, State 1, Line 2
Cannot drop schema 'cdc' because it is being referenced by object 'fn_cdc_get_all_changes_ ... '.
But it is not - as you see above – as in the sys.objects table there are still 4 “strange” entries and the schema can’t be deleted.
schema_name | function_name |
cdc | fn_cdc_get_all_changes_... |
cdc | fn_cdc_get_net_changes_... |
cdc | fn_cdc_get_all_changes_ ... |
cdc | fn_cdc_get_net_changes_ ... |
Those functions obviously do not exists anywhere else except sys.objects table.
So what can be done? I even tried to delete those entries from sys.objects – but it wasn’t possible:
Msg 259, Level 16, State 1, Line 6
Ad hoc updates to system catalogs are not allowed.
So the question is – what can be done to enable CDC on the migrated database again?
Best Regards,
Darek