- assume your database name is : DB1.
- assume Your last backup of DB1 which cdc tables are exists is : DBbk.
- restore DBbk.You can script those objects from this database in which you have successfully enabled CDC.
- authorize cdc user in DB1.
- mark created cdc tables as system tables in DB1.
- fill DB1 cdc tables from DBbk.
- do this proccess for all cdc tables which are exists in DBbk and are not exists in DB1.
- create a needed index on cdc.change_table.
- in security section , change cdc user , db role to 'db_owner'
- in security section , correct schema owner to its owner not to cdc
- now you can disable cdc and enable it again.
.
/* scripts step 1..6 */
use DB1
GO
/****** Object: Table [cdc].[captured_columns] Script Date: 02/11/2013 18:12:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [cdc].[captured_columns](
[object_id] [int] NOT NULL,
[column_name] [sysname] NOT NULL,
[column_id] [int] NULL,
[column_type] [sysname] NOT NULL,
[column_ordinal] [int] NOT NULL,
[is_computed] [bit] NULL,
CONSTRAINT [captured_columns_clustered_idx] PRIMARY KEY CLUSTERED
(
[object_id] ASC,
[column_ordinal] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
----------------------------
alter authorization on schema::[cdc] to [cdc]
----------------------------
exec sp_MS_marksystemobject '[cdc].[captured_columns]';
---------------------------
insert into [cdc].[captured_columns]
SELECT * FROM [DBbk].[cdc].[captured_columns];
/* scripts step 8 */
/****** Object: Index [source_object_id_idx] Script Date: 02/11/2013 18:44:00 ******/
CREATE NONCLUSTERED INDEX [source_object_id_idx] ON [cdc].[change_tables]
(
[source_object_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO