Monday, June 6, 2011

CDC concept in SQL Server 2008

declare @rc int
exec @rc = sys.sp_cdc_enable_db
select @rc
-- new column added to sys.databases: is_cdc_enabled
select name, is_cdc_enabled from sys.databases

Go
create table dbo.customer1
(
id int identity not null
, name varchar(50) not null
, state varchar(2) not null
, constraint pk_customer primary key clustered (id)
)

Go

exec sys.sp_cdc_enable_table
@source_schema = 'dbo',
@source_name = 'customer1' ,
@role_name = 'CDCRole',
@supports_net_changes = 1

select name, type, type_desc, is_tracked_by_cdc from sys.tables