May 7, 2012

sp_MScdc_capture_job (Transact-SQL MetaData) Definition

Please note: that the following source code is provided and copyrighted by Microsoft and is for educational purpose only.
The meta data is from an SQL 2012 Server.

I have posted alot more, find the whole list here.

Goto Definition or MetaData

Definition:

sys.sp_MScdc_capture_job()

MetaData:

   
create procedure [sys].[sp_MScdc_capture_job]
as
begin
set nocount on
declare @retcode int
,@pollinginterval bigint
,@continuous bit
,@maxtrans int
,@maxscans int
,@db_name sysname

set @db_name = db_name()

--
-- security check - should be dbo or sysadmin
--
exec @retcode = sp_MSreplcheck_publish
if @@ERROR != 0 or @retcode != 0
begin
raiserror(22864, 16, -1, @db_name)
return 1
end

--
-- security check
-- Has to be executed from cdc enabled db
--
if not exists (select * from sys.databases where database_id = db_id() and is_cdc_enabled = 1)
begin
RAISERROR(22901, 16, -1, @db_name)
return (1)
end

--
-- Insure that transactional replication is not also trying to scan the log
--
exec @retcode = [sys].[sp_MScdc_tranrepl_check]
if @retcode <> 0 or @@error <> 0
begin
raiserror(22864, 16, -1, @db_name)
return 1
end

-- Get job parameters for msdb.cdc_jobs
exec @retcode = sys.sp_cdc_get_job_parameters
@pollinginterval output
,@continuous output
,@maxscans output
,@maxtrans output

if (@@error <> 0) or (@retcode <> 0)
begin
raiserror(22864, 16, -1, @db_name)
return 1
end

if @continuous is null
set @continuous = 1

if @maxtrans is null
set @maxtrans = 500

if @maxscans is null
set @maxscans = 10

if @pollinginterval is null
if @continuous = 1
set @pollinginterval = 5
else
set @pollinginterval = 0

exec @retcode = sp_cdc_scan
@pollinginterval = @pollinginterval
,@continuous = @continuous
,@maxtrans = @maxtrans
,@maxscans = @maxscans
,@is_from_job = 1

if @retcode <> 0 or @@error <> 0
begin
raiserror(22864, 16, -1, @db_name)
return 1
end

return 0
END

No comments:

Post a Comment

Total Pageviews