Translate

Monday, March 29, 2010

Re-indexing/ Reorganizing a Table after Enabling CDC

In SQL Server 2008 there is a new feature named CDC where you can capture data changes. Sorry this blog entry is not going to discuss about how to work with CDC instead this is an issue which I faced after enabling CDC.

I enabled CDC for a table called CDC with following syntax.

EXEC sys.sp_cdc_enable_table

@source_schema = N'dbo',

@source_name   = N'data',

@role_name     = N'dbo',

@supports_net_changes = 1

GO

Then I performed a re-organize for that table.

USE [COB]

GO

ALTER INDEX [PK_Data] ON [dbo].[Data] REORGANIZE WITH ( LOB_COMPACTION = ON )

GO

Then it returned the following error.

Msg 22983, Level 16, State 1, Procedure sp_cdc_ddl_event_internal, Line 77

The unique index 'PK_Data' on source table '[dbo].[Data]' is used by Change Data Capture. To alter or drop the index, you must first disable Change Data Capture on the table.

Msg 3609, Level 16, State 2, Line 1

The transaction ended in the trigger. The batch has been aborted.

Same error will appear if I do a re-indexing.

This bug is fixed with Cumulative update package 6 for SQL Server 2008 Service Pack 1

No comments:

Post a Comment