April 30, 2012

sp_IHadd_sync_command (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_IHadd_sync_command(smallint @publisher_id
, nvarchar @publisher_db
, varbinary @xact_id
, varbinary @xact_seqno
, nvarchar @originator
, nvarchar @originator_db
, int @article_id
, int @command_id
, int @type
, bit @partial_command
, varbinary @command
, nvarchar @publisher)

MetaData:

   
CREATE PROCEDURE sys.sp_IHadd_sync_command
(
@publisher_id smallint = NULL,
@publisher_db sysname,
@xact_id varbinary(16) = 0x0,
@xact_seqno varbinary(16) = 0x0,
@originator sysname = NULL,
@originator_db sysname = NULL,
@article_id int = NULL,
@command_id int = 1,
@type int = NULL,
@partial_command bit = NULL,
@command varbinary(1024) = NULL,
@publisher sysname = NULL
)
AS
BEGIN
SET NOCOUNT ON

declare @retcode int
DECLARE @date datetime
DECLARE @publisher_database_id int
declare @originator_id int
DECLARE @syncmask int
DECLARE @snapshot_bit int

select @snapshot_bit = 0x80000000

SELECT @date = GETDATE()

-- -- -- -- security check, db_owner
exec @retcode = sys.sp_MSreplcheck_publish
if @@ERROR <> 0 or @retcode <> 0
return(1)

if @publisher_id is NULL
select @publisher_id = srvid from master.dbo.sysservers where
UPPER(srvname collate database_default) = UPPER(@publisher)

-- Get publisher database id.
SELECT @publisher_database_id = id from MSpublisher_databases where publisher_id = @publisher_id and
publisher_db = @publisher_db

IF @command_id = 1
BEGIN
INSERT INTO MSrepl_transactions VALUES (@publisher_database_id,
@xact_id, @xact_seqno, @date)
IF @@ERROR <> 0
RETURN 1
END

IF @command IS NOT NULL
begin
if @originator <> N'' and @originator_db <> N'' and @originator is not null and @originator_db is not null
begin
set @originator_id = null select @originator_id = id from MSrepl_originators where
publisher_database_id = @publisher_database_id and UPPER(srvname) = UPPER(@originator) and
dbname = @originator_db
if @originator_id is null
begin
insert into MSrepl_originators (publisher_database_id, srvname, dbname) values
(@publisher_database_id, UPPER(@originator), @originator_db)
select @originator_id = @@identity
end
end
else
select @originator_id = 0


if( @type in( 37,38 ) )
begin
declare @syncstat int
select @syncstat = 38 - @type
exec sp_MSset_syncstate @publisher_id, @publisher_db, @article_id, @syncstat, @xact_seqno
end

INSERT INTO MSrepl_commands (publisher_database_id, xact_seqno, type, article_id, originator_id, command_id, partial_command, command)
VALUES (@publisher_database_id, @xact_seqno,
@type | @snapshot_bit, @article_id, @originator_id, @command_id, @partial_command, @command)
end

IF @@ERROR <> 0
RETURN (1)
END

No comments:

Post a Comment

Total Pageviews