SQL Server Restore Error – Could Not Upgrade Metadata

change-data-capturerestoresql serversql-server-2012

I am trying to restore a database from a Prod environment (11.0.6020.0) to a lower environment server (11.0.3128.0). I realize the lower has an older SP, we are working on correcting that now. The restore should still work though, it has for months, but I'm getting the following error message. We just recently enabled this database for CDC, I'm not specifying keep_cdc in the restore. Anybody seen this error before and know how to resolve it?

Msg 22841, Level 16, State 1, Procedure sp_cdc_vupgrade, Line 320
[Batch Start Line 0] Could not upgrade the metadata for database
'DBName' that is enabled for Change Data Capture. The failure occurred
when executing the action 'alter cdc.change_tables index
change_tables_unique_idx with (drop_existing = on)'. The error
returned was 4922: 'line 102, state 9, ALTER TABLE ALTER COLUMN
column_id failed because one or more objects access this column.'. Use
the action and error to determine the cause of the failure and
resubmit the request.

RESTORE DATABASE [DBName] 
FROM  DISK = @FileToRestore WITH  
MOVE  'DBName' to 'W:\Data\DBName\DBName.mdf',
MOVE  'AmexDB_log' to 'W:\Logs\DBName\DBName_Log.ldf',
NOUNLOAD, REPLACE , FILE = 1, STATS = 10
GO

Best Answer

We were able to resolve the issue by upgrading the lower environment to SP3. Once that was done the restore completed without any errors.