Saturday, May 23, 2009

Restore a CDC Enabled Database

You might not be able to restore a CDC Enabled DB from a backup using the GUI(Management Studio). Below is the script which explicitly mentions about KEEP_CDC. Once you restore the DB, enable the cleanup and capture job and the DB should be completely up with CDC enabled.

RESTORE DATABASE Sample
FROM DISK = N'E:\SQLBackup\Sample_07232009_1058.bak'
WITH FILE = 1,
MOVE N'Sample' TO N'E:\Program Files\Microsoft SQL Server\MSSQL10.SQLDEV\MSSQL\DATA\Sample.mdf',
MOVE N'Sample_log' TO N'E:\Program Files\Microsoft SQL Server\MSSQL10.SQLDEV\MSSQL\DATA\Sample_1.ldf',
NOUNLOAD,
STATS = 10,
KEEP_CDC
GO

and then

USE Sample
GO
EXEC sys.sp_cdc_add_job @job_type = N'cleanup'
GO
EXEC sys.sp_cdc_add_job @job_type = N'capture'
GO

2 comments:

Unknown said...

I’m impressed, I have to say. Actually hardly ever do I encounter a weblog that’s each educative and entertaining, and let me let you know, you've gotten hit the nail on the head. Your concept is outstanding; the issue is something that not enough persons are speaking intelligently about. I am very completely satisfied that I stumbled across this in my search for one thing referring to this. best online casinos

fillikir72518 said...

An interesting discussion is worth comment. I believe that you need to write extra on this topic, it might not be a taboo topic but generally persons are not sufficient to talk on such topics. To the next. Cheers real money casino