Re: Transactional Replication Problem

From: Ahmed Hashish (a_hashish_at_hotmail.com)
Date: 01/12/05


Date: Wed, 12 Jan 2005 09:32:51 +0200

CREATE TABLE [dbo].[Persons] (
 [PersonCode] [varchar] (10) COLLATE SQL_Latin1_General_CP1256_CI_AS NOT
NULL ,
 [PersonType] [int] NOT NULL ,
 [PersonName] [varchar] (100) COLLATE SQL_Latin1_General_CP1256_CI_AS NOT
NULL ,
 [BranchCode] [varchar] (3) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [CurrencyCode] [varchar] (3) COLLATE SQL_Latin1_General_CP1256_CI_AS NOT
NULL ,
 [AccCode] [varchar] (15) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [OurAccountNum] [varchar] (15) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL
,
 [CenterCode] [varchar] (2) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [CategoryCode] [int] NOT NULL ,
 [CreditLimit] [float] NOT NULL ,
 [Rank] [int] NOT NULL ,
 [Address] [varchar] (100) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [ShipAddress] [varchar] (100) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL
,
 [PoBox] [varchar] (20) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [ShipPoBox] [varchar] (20) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [Fax] [varchar] (20) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [AltrFax] [varchar] (20) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [ShipFax] [varchar] (20) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [ShipAltrFax] [varchar] (20) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [Phone] [varchar] (20) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [AltrPhone] [varchar] (20) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [ShipPhone] [varchar] (20) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [ShipAltrPhone] [varchar] (20) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL
,
 [Telx] [varchar] (20) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [AltrTelx] [varchar] (20) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [ShipTelx] [varchar] (20) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [ShipAltrTelx] [varchar] (20) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL
,
 [Contact] [varchar] (50) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [ContactTitle] [varchar] (50) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL
,
 [OthContact] [varchar] (50) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [OthContactTitle] [varchar] (50) COLLATE SQL_Latin1_General_CP1256_CI_AS
NULL ,
 [E_Mail] [varchar] (100) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [Notes] [varchar] (300) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [PersonGroupID] [varchar] (10) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL
,
 [ContactCode] [varchar] (10) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [PmtTerms] [varchar] (30) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [UserName] [varchar] (50) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL ,
 [PersonAltrName] [varchar] (100) COLLATE SQL_Latin1_General_CP1256_CI_AS
NULL ,
 [Active] [int] NOT NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Persons] WITH NOCHECK ADD
 CONSTRAINT [PK_Persons] PRIMARY KEY CLUSTERED
 (
  [PersonCode]
 ) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Persons] WITH NOCHECK ADD
 CONSTRAINT [DF_Names_NameType] DEFAULT (0) FOR [PersonType],
 CONSTRAINT [DF_Persons_BranchCode] DEFAULT ('J') FOR [BranchCode],
 CONSTRAINT [DF_Persons_CurrencyCode] DEFAULT ('001') FOR [CurrencyCode],
 CONSTRAINT [DF_Persons_CreditLimit] DEFAULT (0) FOR [CreditLimit],
 CONSTRAINT [DF_Persons_Rank] DEFAULT (0) FOR [Rank],
 CONSTRAINT [DF__Persons__Active__3FA65AF7] DEFAULT (1) FOR [Active]
GO

 CREATE INDEX [PersonType] ON [dbo].[Persons]([PersonType]) ON [PRIMARY]
GO

 CREATE INDEX [PersonName] ON [dbo].[Persons]([PersonName]) ON [PRIMARY]
GO

 CREATE INDEX [BranchCode] ON [dbo].[Persons]([BranchCode]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Persons] ADD
 CONSTRAINT [FK_Persons_PersonTypes] FOREIGN KEY
 (
  [PersonType]
 ) REFERENCES [dbo].[PersonTypes] (
  [TypeCode]
 )
GO

/****** Scripting the replication setup of server KHOBARSQLSERVER. Script
Date: 11/01/2005 1:03:13 PM ******/
/****** Please note: Any password parameter was scripted with NULL or empty
string for security reason. ******/

/****** Begin: Script to be run at Distributor: KHOBARSQLSERVER ******/
/****** Object: Job Replication agents checkup Script Date: 11/01/2005
1:03:13 PM ******/
begin transaction
  DECLARE @JobID BINARY(16)
  DECLARE @ReturnCode INT
  SELECT @ReturnCode = 0
if (select count(*) from msdb.dbo.syscategories where name =
N'REPL-Checkup') < 1
  execute msdb.dbo.sp_add_category N'REPL-Checkup'

select @JobID = job_id from msdb.dbo.sysjobs where (name = N'Replication
agents checkup')
if (@JobID is NULL)
BEGIN
  execute @ReturnCode = msdb.dbo.sp_add_job @job_id = @JobID OUTPUT,
@job_name = N'Replication agents checkup', @enabled = 1, @start_step_id = 1,
@notify_level_eventlog = 2, @notify_level_email = 0, @notify_level_netsend =
0, @notify_level_page = 0, @delete_level = 0, @description = N'Detects
replication agents that are not logging history actively.', @category_name =
N'REPL-Checkup', @owner_login_name = N'sa'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @JobID , @step_id
= 1, @cmdexec_success_code = 0, @on_success_action = 1, @on_success_step_id
= 0, @on_fail_action = 2, @on_fail_step_id = 0, @retry_attempts = 0,
@retry_interval = 0, @os_run_priority = 0, @flags = 0, @step_name = N'Run
agent.', @subsystem = N'TSQL', @command = N'sp_replication_agent_checkup
@heartbeat_interval = 10', @database_name = N'master'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_update_job @job_id = @JobID,
@start_step_id = 1
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @JobID, @name
= N'Replication agent schedule.', @enabled = 1, @freq_type = 4,
@freq_interval = 1, @freq_subday_type = 4, @freq_subday_interval = 10,
@freq_relative_interval = 1, @freq_recurrence_factor = 0, @active_start_date
= 20050106, @active_end_date = 99991231, @active_start_time = 0,
@active_end_time = 235959
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @JobID,
@server_name = N'khobarsqlserver'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

END

commit transaction
goto EndSave
QuitWithRollback:
  if (@@TRANCOUNT > 0) rollback transaction
EndSave:

GO

/****** Object: Job Reinitialize subscriptions having data validation
failures Script Date: 11/01/2005 1:03:13 PM ******/
begin transaction
  DECLARE @JobID BINARY(16)
  DECLARE @ReturnCode INT
  SELECT @ReturnCode = 0
if (select count(*) from msdb.dbo.syscategories where name = N'REPL-Alert
Response') < 1
  execute msdb.dbo.sp_add_category N'REPL-Alert Response'

select @JobID = job_id from msdb.dbo.sysjobs where (name = N'Reinitialize
subscriptions having data validation failures')
if (@JobID is NULL)
BEGIN
  execute @ReturnCode = msdb.dbo.sp_add_job @job_id = @JobID OUTPUT,
@job_name = N'Reinitialize subscriptions having data validation failures',
@enabled = 1, @start_step_id = 1, @notify_level_eventlog = 0,
@notify_level_email = 0, @notify_level_netsend = 0, @notify_level_page = 0,
@delete_level = 0, @description = N'Reinitializes all subscriptions that
have data validation failures.', @category_name = N'REPL-Alert Response',
@owner_login_name = N'sa'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @JobID , @step_id
= 1, @cmdexec_success_code = 0, @on_success_action = 1, @on_success_step_id
= 0, @on_fail_action = 2, @on_fail_step_id = 0, @retry_attempts = 0,
@retry_interval = 0, @os_run_priority = 0, @flags = 0, @step_name = N'Run
agent.', @subsystem = N'TSQL', @command = N'exec
dbo.sp_MSreinit_failed_subscriptions @failure_level = 1', @server =
N'KHOBARSQLSERVER', @database_name = N'master'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_update_job @job_id = @JobID,
@start_step_id = 1
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @JobID,
@server_name = N'khobarsqlserver'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

END

commit transaction
goto EndSave
QuitWithRollback:
  if (@@TRANCOUNT > 0) rollback transaction
EndSave:

GO

/****** Installing the server KHOBARSQLSERVER as a Distributor. Script Date:
11/01/2005 1:03:13 PM ******/
use master
GO

exec sp_adddistributor @distributor = N'KHOBARSQLSERVER', @password = N'',
@from_scripting = 1
GO

-- Updating the agent profile defaults
sp_MSupdate_agenttype_default @profile_id = 1
GO
sp_MSupdate_agenttype_default @profile_id = 2
GO
sp_MSupdate_agenttype_default @profile_id = 4
GO
sp_MSupdate_agenttype_default @profile_id = 6
GO
sp_MSupdate_agenttype_default @profile_id = 11
GO

-- Adding the distribution database
exec sp_adddistributiondb @database = N'distribution', @data_folder =
N'd:\Program Files\Microsoft SQL Server\MSSQL\DATA', @data_file =
N'distribution_Data', @data_file_size = 3, @log_folder = N'd:\Program
Files\Microsoft SQL Server\MSSQL\DATA', @log_file = N'distribution_Log',
@log_file_size = 1, @min_distretention = 0, @max_distretention = 32000,
@history_retention = 48, @security_mode = 0, @login = N'sa', @password =
null, @from_scripting = 1
GO

/****** Object: Job Distribution clean up: distribution Script Date:
11/01/2005 1:03:13 PM ******/
begin transaction
  DECLARE @JobID BINARY(16)
  DECLARE @ReturnCode INT
  SELECT @ReturnCode = 0
if (select count(*) from msdb.dbo.syscategories where name =
N'REPL-Distribution Cleanup') < 1
  execute msdb.dbo.sp_add_category N'REPL-Distribution Cleanup'

select @JobID = job_id from msdb.dbo.sysjobs where (name = N'Distribution
clean up: distribution')
if (@JobID is NULL)
BEGIN
  execute @ReturnCode = msdb.dbo.sp_add_job @job_id = @JobID OUTPUT,
@job_name = N'Distribution clean up: distribution', @enabled = 1,
@start_step_id = 1, @notify_level_eventlog = 0, @notify_level_email = 0,
@notify_level_netsend = 0, @notify_level_page = 0, @delete_level = 0,
@description = N'Removes replicated transactions from the distribution
database.', @category_name = N'REPL-Distribution Cleanup', @owner_login_name
= N'sa'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @JobID , @step_id
= 1, @cmdexec_success_code = 0, @on_success_action = 1, @on_success_step_id
= 0, @on_fail_action = 2, @on_fail_step_id = 0, @retry_attempts = 0,
@retry_interval = 0, @os_run_priority = 0, @flags = 0, @step_name = N'Run
agent.', @subsystem = N'TSQL', @command = N'EXEC
dbo.sp_MSdistribution_cleanup @min_distretention = 0, @max_distretention =
32000', @server = N'KHOBARSQLSERVER', @database_name = N'distribution'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_update_job @job_id = @JobID,
@start_step_id = 1
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback
  execute @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @JobID, @name
= N'Replication agent schedule.', @enabled = 1, @freq_type = 4,
@freq_interval = 1, @freq_subday_type = 4, @freq_subday_interval = 10,
@freq_relative_interval = 1, @freq_recurrence_factor = 0, @active_start_date
= 20050106, @active_end_date = 99991231, @active_start_time = 500,
@active_end_time = 459
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @JobID,
@server_name = N'khobarsqlserver'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

END

commit transaction
goto EndSave
QuitWithRollback:
  if (@@TRANCOUNT > 0) rollback transaction
EndSave:

GO

/****** Object: Job Agent history clean up: distribution Script Date:
11/01/2005 1:03:13 PM ******/
begin transaction
  DECLARE @JobID BINARY(16)
  DECLARE @ReturnCode INT
  SELECT @ReturnCode = 0
if (select count(*) from msdb.dbo.syscategories where name = N'REPL-History
Cleanup') < 1
  execute msdb.dbo.sp_add_category N'REPL-History Cleanup'

select @JobID = job_id from msdb.dbo.sysjobs where (name = N'Agent history
clean up: distribution')
if (@JobID is NULL)
BEGIN
  execute @ReturnCode = msdb.dbo.sp_add_job @job_id = @JobID OUTPUT,
@job_name = N'Agent history clean up: distribution', @enabled = 1,
@start_step_id = 1, @notify_level_eventlog = 0, @notify_level_email = 0,
@notify_level_netsend = 0, @notify_level_page = 0, @delete_level = 0,
@description = N'Removes replication agent history from the distribution
database.', @category_name = N'REPL-History Cleanup', @owner_login_name =
N'sa'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @JobID , @step_id
= 1, @cmdexec_success_code = 0, @on_success_action = 1, @on_success_step_id
= 0, @on_fail_action = 2, @on_fail_step_id = 0, @retry_attempts = 0,
@retry_interval = 0, @os_run_priority = 0, @flags = 0, @step_name = N'Run
agent.', @subsystem = N'TSQL', @command = N'EXEC dbo.sp_MShistory_cleanup
@history_retention = 48', @server = N'KHOBARSQLSERVER', @database_name =
N'distribution'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_update_job @job_id = @JobID,
@start_step_id = 1
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @JobID, @name
= N'Replication agent schedule.', @enabled = 1, @freq_type = 4,
@freq_interval = 1, @freq_subday_type = 4, @freq_subday_interval = 10,
@freq_relative_interval = 1, @freq_recurrence_factor = 0, @active_start_date
= 20050106, @active_end_date = 99991231, @active_start_time = 0,
@active_end_time = 235959
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @JobID,
@server_name = N'khobarsqlserver'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

END

commit transaction
goto EndSave
QuitWithRollback:
  if (@@TRANCOUNT > 0) rollback transaction
EndSave:

GO

-- Adding the distribution publisher
exec sp_adddistpublisher @publisher = N'KHOBARSQLSERVER', @distribution_db
= N'distribution', @security_mode = 1, @working_directory = N'd:\Program
Files\Microsoft SQL Server\MSSQL\REPLDATA', @trusted = N'false',
@thirdparty_flag = 0
GO

/****** Object: Job KHOBARSQLSERVER-MISDB-1 Script Date: 11/01/2005
1:03:13 PM ******/
begin transaction
  DECLARE @JobID BINARY(16)
  DECLARE @ReturnCode INT
  SELECT @ReturnCode = 0
if (select count(*) from msdb.dbo.syscategories where name =
N'REPL-LogReader') < 1
  execute msdb.dbo.sp_add_category N'REPL-LogReader'

select @JobID = job_id from msdb.dbo.sysjobs where (name =
N'KHOBARSQLSERVER-MISDB-1')
if (@JobID is NULL)
BEGIN
  execute @ReturnCode = msdb.dbo.sp_add_job @job_id = @JobID OUTPUT,
@job_name = N'KHOBARSQLSERVER-MISDB-1', @enabled = 1, @start_step_id = 1,
@notify_level_eventlog = 0, @notify_level_email = 0, @notify_level_netsend =
0, @notify_level_page = 0, @delete_level = 0, @description = N'No
description available.', @category_name = N'REPL-LogReader',
@owner_login_name = N'sa'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @JobID , @step_id
= 1, @cmdexec_success_code = 0, @on_success_action = 3, @on_success_step_id
= 0, @on_fail_action = 3, @on_fail_step_id = 0, @retry_attempts = 0,
@retry_interval = 0, @os_run_priority = 0, @flags = 0, @step_name = N'Log
Reader Agent startup message.', @subsystem = N'TSQL', @command =
N'sp_MSadd_logreader_history @perfmon_increment = 0, @agent_id = 1,
@runstatus = 1,
     @comments = ''Starting agent.''', @server = N'KHOBARSQLSERVER',
@database_name = N'distribution'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @JobID , @step_id
= 2, @cmdexec_success_code = 0, @on_success_action = 1, @on_success_step_id
= 0, @on_fail_action = 3, @on_fail_step_id = 0, @retry_attempts = 10,
@retry_interval = 1, @os_run_priority = 0, @flags = 0, @step_name = N'Run
agent.', @subsystem = N'LogReader', @command = N'-Publisher
[KHOBARSQLSERVER] -PublisherDB [MISDB] -Distributor
[KHOBARSQLSERVER] -DistributorSecurityMode 1 -Continuous', @server =
N'KHOBARSQLSERVER', @database_name = N'distribution'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @JobID , @step_id
= 3, @cmdexec_success_code = 0, @on_success_action = 2, @on_success_step_id
= 0, @on_fail_action = 2, @on_fail_step_id = 0, @retry_attempts = 0,
@retry_interval = 0, @os_run_priority = 0, @flags = 0, @step_name = N'Detect
nonlogged agent shutdown.', @subsystem = N'TSQL', @command =
N'sp_MSdetect_nonlogged_shutdown @subsystem = ''LogReader'', @agent_id = 1',
@server = N'KHOBARSQLSERVER', @database_name = N'distribution'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_update_job @job_id = @JobID,
@start_step_id = 1
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @JobID, @name
= N'Replication agent schedule.', @enabled = 1, @freq_type = 64,
@freq_interval = 0, @freq_subday_type = 0, @freq_subday_interval = 0,
@freq_relative_interval = 0, @freq_recurrence_factor = 0, @active_start_date
= 20050106, @active_end_date = 99991231, @active_start_time = 0,
@active_end_time = 235959
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @JobID,
@server_name = N'khobarsqlserver'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

END

commit transaction
goto EndSave
QuitWithRollback:
  if (@@TRANCOUNT > 0) rollback transaction
EndSave:

GO

/****** Object: Job KHOBARSQLSERVER-MISDB-KHO_Pub-1 Script Date:
11/01/2005 1:03:13 PM ******/
begin transaction
  DECLARE @JobID BINARY(16)
  DECLARE @ReturnCode INT
  SELECT @ReturnCode = 0
if (select count(*) from msdb.dbo.syscategories where name =
N'REPL-Snapshot') < 1
  execute msdb.dbo.sp_add_category N'REPL-Snapshot'

select @JobID = job_id from msdb.dbo.sysjobs where (name =
N'KHOBARSQLSERVER-MISDB-KHO_Pub-1')
if (@JobID is NULL)
BEGIN
  execute @ReturnCode = msdb.dbo.sp_add_job @job_id = @JobID OUTPUT,
@job_name = N'KHOBARSQLSERVER-MISDB-KHO_Pub-1', @enabled = 1, @start_step_id
= 1, @notify_level_eventlog = 0, @notify_level_email = 0,
@notify_level_netsend = 0, @notify_level_page = 0, @delete_level = 0,
@description = N'No description available.', @category_name =
N'REPL-Snapshot', @owner_login_name = N'sa'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @JobID , @step_id
= 1, @cmdexec_success_code = 0, @on_success_action = 3, @on_success_step_id
= 0, @on_fail_action = 3, @on_fail_step_id = 0, @retry_attempts = 0,
@retry_interval = 0, @os_run_priority = 0, @flags = 0, @step_name = N'Log
Reader Agent startup message.', @subsystem = N'TSQL', @command =
N'sp_MSadd_snapshot_history @perfmon_increment = 0, @agent_id = 1,
@runstatus = 1,
     @comments = ''Starting agent.''', @server = N'KHOBARSQLSERVER',
@database_name = N'distribution'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @JobID , @step_id
= 2, @cmdexec_success_code = 0, @on_success_action = 1, @on_success_step_id
= 0, @on_fail_action = 3, @on_fail_step_id = 0, @retry_attempts = 10,
@retry_interval = 1, @os_run_priority = 0, @flags = 0, @step_name = N'Run
agent.', @subsystem = N'Snapshot', @command = N'-Publisher
[KHOBARSQLSERVER] -PublisherDB [MISDB] -Distributor
[KHOBARSQLSERVER] -Publication [KHO_Pub] -DistributorSecurityMode 1 ',
@server = N'KHOBARSQLSERVER', @database_name = N'distribution'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @JobID , @step_id
= 3, @cmdexec_success_code = 0, @on_success_action = 2, @on_success_step_id
= 0, @on_fail_action = 2, @on_fail_step_id = 0, @retry_attempts = 0,
@retry_interval = 0, @os_run_priority = 0, @flags = 0, @step_name = N'Detect
nonlogged agent shutdown.', @subsystem = N'TSQL', @command =
N'sp_MSdetect_nonlogged_shutdown @subsystem = ''Snapshot'', @agent_id = 1',
@server = N'KHOBARSQLSERVER', @database_name = N'distribution'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_update_job @job_id = @JobID,
@start_step_id = 1
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @JobID, @name
= N'Replication agent schedule.', @enabled = 1, @freq_type = 4,
@freq_interval = 1, @freq_subday_type = 8, @freq_subday_interval = 1,
@freq_relative_interval = 1, @freq_recurrence_factor = 0, @active_start_date
= 20050106, @active_end_date = 99991231, @active_start_time = 0,
@active_end_time = 235959
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @JobID,
@server_name = N'khobarsqlserver'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

END

commit transaction
goto EndSave
QuitWithRollback:
  if (@@TRANCOUNT > 0) rollback transaction
EndSave:

GO

/****** End: Script to be run at Distributor: KHOBARSQLSERVER ******/

/****** Begin: Script to be run at Publisher: KHOBARSQLSERVER ******/
-- Adding the registered subscriber
exec sp_addsubscriber @subscriber = N'JEDSQLSERVER', @type = 0, @login =
N'sa', @password = N'', @security_mode = 0, @frequency_type = 64,
@frequency_interval = 1, @frequency_relative_interval = 2,
@frequency_recurrence_factor = 0, @frequency_subday = 8,
@frequency_subday_interval = 1, @active_start_date = 0, @active_end_date =
0, @active_start_time_of_day = 0, @active_end_time_of_day = 235900,
@description = N''
 exec sp_changesubscriber_schedule @subscriber = N'JEDSQLSERVER',
@agent_type = 1
GO

/****** Object: Job Expired subscription clean up Script Date:
11/01/2005 1:03:13 PM ******/
begin transaction
  DECLARE @JobID BINARY(16)
  DECLARE @ReturnCode INT
  SELECT @ReturnCode = 0
if (select count(*) from msdb.dbo.syscategories where name =
N'REPL-Subscription Cleanup') < 1
  execute msdb.dbo.sp_add_category N'REPL-Subscription Cleanup'

select @JobID = job_id from msdb.dbo.sysjobs where (name = N'Expired
subscription clean up')
if (@JobID is NULL)
BEGIN
  execute @ReturnCode = msdb.dbo.sp_add_job @job_id = @JobID OUTPUT,
@job_name = N'Expired subscription clean up', @enabled = 1, @start_step_id =
1, @notify_level_eventlog = 0, @notify_level_email = 0,
@notify_level_netsend = 0, @notify_level_page = 0, @delete_level = 0,
@description = N'Detects and removes expired subscriptions from published
databases.', @category_name = N'REPL-Subscription Cleanup',
@owner_login_name = N'sa'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @JobID , @step_id
= 1, @cmdexec_success_code = 0, @on_success_action = 1, @on_success_step_id
= 0, @on_fail_action = 2, @on_fail_step_id = 0, @retry_attempts = 0,
@retry_interval = 0, @os_run_priority = 0, @flags = 0, @step_name = N'Run
agent.', @subsystem = N'TSQL', @command = N'EXEC
dbo.sp_expired_subscription_cleanup', @server = N'KHOBARSQLSERVER',
@database_name = N'MISDB'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_update_job @job_id = @JobID,
@start_step_id = 1
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @JobID, @name
= N'Replication agent schedule.', @enabled = 1, @freq_type = 4,
@freq_interval = 1, @freq_subday_type = 1, @freq_subday_interval = 1,
@freq_relative_interval = 1, @freq_recurrence_factor = 0, @active_start_date
= 20050106, @active_end_date = 99991231, @active_start_time = 10000,
@active_end_time = 235959
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

  execute @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @JobID,
@server_name = N'khobarsqlserver'
  if (@@ERROR <> 0 OR @ReturnCode <> 0) goto QuitWithRollback

END

commit transaction
goto EndSave
QuitWithRollback:
  if (@@TRANCOUNT > 0) rollback transaction
EndSave:

GO

-- Enabling the replication database
use master
GO

exec sp_replicationdboption @dbname = N'MISDB', @optname = N'publish',
@value = N'true'
GO

use [MISDB]
GO

-- Adding the transactional publication
exec sp_addpublication @publication = N'KHO_Pub', @restricted = N'false',
@sync_method = N'native', @repl_freq = N'continuous', @description = N'MIS
Transactional publication.', @status = N'active', @allow_push = N'true',
@allow_pull = N'true', @allow_anonymous = N'false', @enabled_for_internet =
N'false', @independent_agent = N'true', @immediate_sync = N'false',
@allow_sync_tran = N'false', @autogen_sync_procs = N'false', @retention =
32000, @allow_queued_tran = N'false', @snapshot_in_defaultfolder = N'true',
@compress_snapshot = N'false', @ftp_port = 21, @ftp_login = N'anonymous',
@allow_dts = N'false', @allow_subscription_copy = N'false',
@add_to_active_directory = N'false', @logreader_job_name =
N'KHOBARSQLSERVER-MISDB-1'
exec sp_addpublication_snapshot @publication = N'KHO_Pub',@frequency_type =
4, @frequency_interval = 1, @frequency_relative_interval = 1,
@frequency_recurrence_factor = 0, @frequency_subday = 8,
@frequency_subday_interval = 1, @active_start_date = 0, @active_end_date =
0, @active_start_time_of_day = 0, @active_end_time_of_day = 235959,
@snapshot_job_name = N'KHOBARSQLSERVER-MISDB-KHO_Pub-1'
GO

exec sp_grant_publication_access @publication = N'KHO_Pub', @login =
N'BUILTIN\Administrators'
GO
exec sp_grant_publication_access @publication = N'KHO_Pub', @login =
N'distributor_admin'
GO
exec sp_grant_publication_access @publication = N'KHO_Pub', @login = N'sa'
GO

-- Adding the transactional articles
exec sp_addarticle @publication = N'KHO_Pub', @article = N'AccJournalCC',
@source_owner = N'dbo', @source_object = N'AccJournalCC', @destination_table
= N'AccJournalCC', @type = N'logbased', @creation_script = null,
@description = null, @pre_creation_cmd = N'drop', @schema_option =
0x00000000000000F3, @status = 16, @vertical_partition = N'false', @ins_cmd =
N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object =
null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'AccJournalDtl',
@source_owner = N'dbo', @source_object = N'AccJournalDtl',
@destination_table = N'AccJournalDtl', @type = N'logbased', @creation_script
= null, @description = null, @pre_creation_cmd = N'drop', @schema_option =
0x00000000000000F3, @status = 16, @vertical_partition = N'false', @ins_cmd =
N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object =
null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'AccJournalHdr',
@source_owner = N'dbo', @source_object = N'AccJournalHdr',
@destination_table = N'AccJournalHdr', @type = N'logbased', @creation_script
= null, @description = null, @pre_creation_cmd = N'drop', @schema_option =
0x00000000000000F3, @status = 16, @vertical_partition = N'false', @ins_cmd =
N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object =
null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'CostingDtl',
@source_owner = N'dbo', @source_object = N'CostingDtl', @destination_table =
N'CostingDtl', @type = N'logbased', @creation_script = null, @description =
null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'CostingHdr',
@source_owner = N'dbo', @source_object = N'CostingHdr', @destination_table =
N'CostingHdr', @type = N'logbased', @creation_script = null, @description =
null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'CostingVch',
@source_owner = N'dbo', @source_object = N'CostingVch', @destination_table =
N'CostingVch', @type = N'logbased', @creation_script = null, @description =
null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'Forecast',
@source_owner = N'dbo', @source_object = N'Forecast', @destination_table =
N'Forecast', @type = N'logbased', @creation_script = null, @description =
null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'ItemSerials',
@source_owner = N'dbo', @source_object = N'ItemSerials', @destination_table
= N'ItemSerials', @type = N'logbased', @creation_script = null, @description
= null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'ItemsInOutH',
@source_owner = N'dbo', @source_object = N'ItemsInOutH', @destination_table
= N'ItemsInOutH', @type = N'logbased', @creation_script = null, @description
= null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'ItemsInOutL',
@source_owner = N'dbo', @source_object = N'ItemsInOutL', @destination_table
= N'ItemsInOutL', @type = N'logbased', @creation_script = null, @description
= null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'PayablesAccDtl',
@source_owner = N'dbo', @source_object = N'PayablesAccDtl',
@destination_table = N'PayablesAccDtl', @type = N'logbased',
@creation_script = null, @description = null, @pre_creation_cmd = N'drop',
@schema_option = 0x00000000000000F3, @status = 16, @vertical_partition =
N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter =
null, @sync_object = null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'PayablesCC',
@source_owner = N'dbo', @source_object = N'PayablesCC', @destination_table =
N'PayablesCC', @type = N'logbased', @creation_script = null, @description =
null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'PayablesHdr',
@source_owner = N'dbo', @source_object = N'PayablesHdr', @destination_table
= N'PayablesHdr', @type = N'logbased', @creation_script = null, @description
= null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'PayablesPurDtl',
@source_owner = N'dbo', @source_object = N'PayablesPurDtl',
@destination_table = N'PayablesPurDtl', @type = N'logbased',
@creation_script = null, @description = null, @pre_creation_cmd = N'drop',
@schema_option = 0x00000000000000F3, @status = 16, @vertical_partition =
N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter =
null, @sync_object = null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'Persons',
@source_owner = N'dbo', @source_object = N'Persons', @destination_table =
N'Persons', @type = N'logbased', @creation_script = null, @description =
null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'Posting',
@source_owner = N'dbo', @source_object = N'Posting', @destination_table =
N'Posting', @type = N'logbased', @creation_script = null, @description =
null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'PurchaseAccDtl',
@source_owner = N'dbo', @source_object = N'PurchaseAccDtl',
@destination_table = N'PurchaseAccDtl', @type = N'logbased',
@creation_script = null, @description = null, @pre_creation_cmd = N'drop',
@schema_option = 0x00000000000000F3, @status = 16, @vertical_partition =
N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter =
null, @sync_object = null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'PurchaseCC',
@source_owner = N'dbo', @source_object = N'PurchaseCC', @destination_table =
N'PurchaseCC', @type = N'logbased', @creation_script = null, @description =
null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'PurchaseDtl',
@source_owner = N'dbo', @source_object = N'PurchaseDtl', @destination_table
= N'PurchaseDtl', @type = N'logbased', @creation_script = null, @description
= null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'PurchaseHdr',
@source_owner = N'dbo', @source_object = N'PurchaseHdr', @destination_table
= N'PurchaseHdr', @type = N'logbased', @creation_script = null, @description
= null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article =
N'PurchaseOrderDtl', @source_owner = N'dbo', @source_object =
N'PurchaseOrderDtl', @destination_table = N'PurchaseOrderDtl', @type =
N'logbased', @creation_script = null, @description = null, @pre_creation_cmd
= N'drop', @schema_option = 0x00000000000000F3, @status = 16,
@vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL',
@upd_cmd = N'SQL', @filter = null, @sync_object = null, @auto_identity_range
= N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article =
N'PurchaseOrderHdr', @source_owner = N'dbo', @source_object =
N'PurchaseOrderHdr', @destination_table = N'PurchaseOrderHdr', @type =
N'logbased', @creation_script = null, @description = null, @pre_creation_cmd
= N'drop', @schema_option = 0x00000000000000F3, @status = 16,
@vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL',
@upd_cmd = N'SQL', @filter = null, @sync_object = null, @auto_identity_range
= N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article =
N'PurchaseReturnDtl', @source_owner = N'dbo', @source_object =
N'PurchaseReturnDtl', @destination_table = N'PurchaseReturnDtl', @type =
N'logbased', @creation_script = null, @description = null, @pre_creation_cmd
= N'drop', @schema_option = 0x00000000000000F3, @status = 16,
@vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL',
@upd_cmd = N'SQL', @filter = null, @sync_object = null, @auto_identity_range
= N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article =
N'PurchaseReturnHdr', @source_owner = N'dbo', @source_object =
N'PurchaseReturnHdr', @destination_table = N'PurchaseReturnHdr', @type =
N'logbased', @creation_script = null, @description = null, @pre_creation_cmd
= N'drop', @schema_option = 0x00000000000000F3, @status = 16,
@vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL',
@upd_cmd = N'SQL', @filter = null, @sync_object = null, @auto_identity_range
= N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article =
N'ReceivablesAccDtl', @source_owner = N'dbo', @source_object =
N'ReceivablesAccDtl', @destination_table = N'ReceivablesAccDtl', @type =
N'logbased', @creation_script = null, @description = null, @pre_creation_cmd
= N'drop', @schema_option = 0x00000000000000F3, @status = 16,
@vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL',
@upd_cmd = N'SQL', @filter = null, @sync_object = null, @auto_identity_range
= N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'ReceivablesCC',
@source_owner = N'dbo', @source_object = N'ReceivablesCC',
@destination_table = N'ReceivablesCC', @type = N'logbased', @creation_script
= null, @description = null, @pre_creation_cmd = N'drop', @schema_option =
0x00000000000000F3, @status = 16, @vertical_partition = N'false', @ins_cmd =
N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object =
null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'ReceivablesHdr',
@source_owner = N'dbo', @source_object = N'ReceivablesHdr',
@destination_table = N'ReceivablesHdr', @type = N'logbased',
@creation_script = null, @description = null, @pre_creation_cmd = N'drop',
@schema_option = 0x00000000000000F3, @status = 16, @vertical_partition =
N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter =
null, @sync_object = null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article =
N'ReceivablesInvDtl', @source_owner = N'dbo', @source_object =
N'ReceivablesInvDtl', @destination_table = N'ReceivablesInvDtl', @type =
N'logbased', @creation_script = null, @description = null, @pre_creation_cmd
= N'drop', @schema_option = 0x00000000000000F3, @status = 16,
@vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL',
@upd_cmd = N'SQL', @filter = null, @sync_object = null, @auto_identity_range
= N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'ReservationDtl',
@source_owner = N'dbo', @source_object = N'ReservationDtl',
@destination_table = N'ReservationDtl', @type = N'logbased',
@creation_script = null, @description = null, @pre_creation_cmd = N'drop',
@schema_option = 0x00000000000000F3, @status = 16, @vertical_partition =
N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter =
null, @sync_object = null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'ReservationHdr',
@source_owner = N'dbo', @source_object = N'ReservationHdr',
@destination_table = N'ReservationHdr', @type = N'logbased',
@creation_script = null, @description = null, @pre_creation_cmd = N'drop',
@schema_option = 0x00000000000000F3, @status = 16, @vertical_partition =
N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter =
null, @sync_object = null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'SalesDtl',
@source_owner = N'dbo', @source_object = N'SalesDtl', @destination_table =
N'SalesDtl', @type = N'logbased', @creation_script = null, @description =
null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'SalesHdr',
@source_owner = N'dbo', @source_object = N'SalesHdr', @destination_table =
N'SalesHdr', @type = N'logbased', @creation_script = null, @description =
null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'SalesOrderDtl',
@source_owner = N'dbo', @source_object = N'SalesOrderDtl',
@destination_table = N'SalesOrderDtl', @type = N'logbased', @creation_script
= null, @description = null, @pre_creation_cmd = N'drop', @schema_option =
0x00000000000000F3, @status = 16, @vertical_partition = N'false', @ins_cmd =
N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object =
null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'SalesOrderHdr',
@source_owner = N'dbo', @source_object = N'SalesOrderHdr',
@destination_table = N'SalesOrderHdr', @type = N'logbased', @creation_script
= null, @description = null, @pre_creation_cmd = N'drop', @schema_option =
0x00000000000000F3, @status = 16, @vertical_partition = N'false', @ins_cmd =
N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object =
null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'SalesReturnDtl',
@source_owner = N'dbo', @source_object = N'SalesReturnDtl',
@destination_table = N'SalesReturnDtl', @type = N'logbased',
@creation_script = null, @description = null, @pre_creation_cmd = N'drop',
@schema_option = 0x00000000000000F3, @status = 16, @vertical_partition =
N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter =
null, @sync_object = null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'SalesReturnHdr',
@source_owner = N'dbo', @source_object = N'SalesReturnHdr',
@destination_table = N'SalesReturnHdr', @type = N'logbased',
@creation_script = null, @description = null, @pre_creation_cmd = N'drop',
@schema_option = 0x00000000000000F3, @status = 16, @vertical_partition =
N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter =
null, @sync_object = null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article =
N'SalQuotationsDtl', @source_owner = N'dbo', @source_object =
N'SalQuotationsDtl', @destination_table = N'SalQuotationsDtl', @type =
N'logbased', @creation_script = null, @description = null, @pre_creation_cmd
= N'drop', @schema_option = 0x00000000000000F3, @status = 16,
@vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL',
@upd_cmd = N'SQL', @filter = null, @sync_object = null, @auto_identity_range
= N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article =
N'SalQuotationsHdr', @source_owner = N'dbo', @source_object =
N'SalQuotationsHdr', @destination_table = N'SalQuotationsHdr', @type =
N'logbased', @creation_script = null, @description = null, @pre_creation_cmd
= N'drop', @schema_option = 0x00000000000000F3, @status = 16,
@vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL',
@upd_cmd = N'SQL', @filter = null, @sync_object = null, @auto_identity_range
= N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'ServiceOrderDtl',
@source_owner = N'dbo', @source_object = N'ServiceOrderDtl',
@destination_table = N'ServiceOrderDtl', @type = N'logbased',
@creation_script = null, @description = null, @pre_creation_cmd = N'drop',
@schema_option = 0x00000000000000F3, @status = 16, @vertical_partition =
N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter =
null, @sync_object = null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'ServiceOrderHdr',
@source_owner = N'dbo', @source_object = N'ServiceOrderHdr',
@destination_table = N'ServiceOrderHdr', @type = N'logbased',
@creation_script = null, @description = null, @pre_creation_cmd = N'drop',
@schema_option = 0x00000000000000F3, @status = 16, @vertical_partition =
N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter =
null, @sync_object = null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'KHO_Pub', @article = N'Stores',
@source_owner = N'dbo', @source_object = N'Stores', @destination_table =
N'Stores', @type = N'logbased', @creation_script = null, @description =
null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3,
@status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd =
N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null,
@auto_identity_range = N'false'
GO

/****** End: Script to be run at Publisher: KHOBARSQLSERVER ******/



Relevant Pages