Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSadd_mergesubentry_indistdb

  No additional text.


Syntax
CREATE PROCEDURE sys.sp_MSadd_mergesubentry_indistdb
(
	@publisher_id smallint,
    @publisher sysname,
    @publisher_db sysname,
    @publication sysname,
    @subscriber sysname,
    @subscriber_db sysname,
    @subscription_type tinyint = 0,     -- 0 = push, 1 = pull, 2=anonymous
    @sync_type tinyint = 1,             -- 0 = none  1 = automatic snaphot  2 = no intial snapshot
    @status tinyint = 1,                -- 0 = inactive, 1 = subscribed, 2 = active
    @description	nvarchar(255) = NULL,
   	@subid uniqueidentifier = NULL,
	@subscriber_version	 int=90
)
as
begin
    set nocount on

    declare @publication_id int
    declare @retcode int
    declare @cur_version int, @rowcount int

    if (sys.fn_MSrepl_isdistdb (db_name()) != 1)
    begin
        raiserror(21482, 16, -1, 'sp_MSadd_anonsubentry_indistdb', 'distribution')
        return (1)
    end

    select @publication_id = publication_id
        from dbo.MSpublications where
        publisher_id = @publisher_id and
        publisher_db = @publisher_db and
        publication = @publication
    if @publication_id is NULL
    begin
        raiserror (20026, 11, -1, @publication)
        return (1)
    end

    exec @retcode = sys.sp_MScheck_pull_access
        @agent_type = 1, -- merge agent
        @publication_id = @publication_id
    if @@error <> 0 or @retcode <> 0
	begin
		RAISERROR (15247, 11, -1)
		return (1)
	end

	select top 1 @cur_version = subscriber_version
	from dbo.MSmerge_subscriptions where subid = @subid
	select @rowcount = @@rowcount
		
	if @rowcount = 0
	begin
		-- if another entry exists but with an incorrect subid, just update the subid.
		if exists (select * from dbo.MSmerge_subscriptions
					where upper(publisher) = upper(@publisher)
					and publisher_db = @publisher_db
					and publication_id = @publication_id
					and upper(subscriber) = upper(@subscriber)
					and subscriber_db = @subscriber_db)
		begin
			update dbo.MSmerge_subscriptions
			set status = @status,
				subscription_type = @subscription_type,
				subscription_time = getdate(),
				description = @description,
				subid = @subid,
				subscriber_version = case when subscriber_version is null then @subscriber_version else subscriber_version end
			where upper(publisher) = upper(@publisher)
					and publisher_db = @publisher_db
					and publication_id = @publication_id
					and upper(subscriber) = upper(@subscriber)
					and subscriber_db = @subscriber_db
					and subscription_type = @subscription_type
			
			if @@error <> 0
				return 1
		end
		else
		begin
		
			insert into dbo.MSmerge_subscriptions (publisher_id, publisher_db, publication_id,
					subscriber_id, subscriber_db, subscription_type, sync_type, status,
					subscription_time, description, publisher, subscriber, subid, subscriber_version)
    			values (@publisher_id, @publisher_db, @publication_id, NULL, @subscriber_db,
    					@subscription_type, @sync_type, @status, getdate(), @description,
						@publisher,	@subscriber, @subid, @subscriber_version)
			
			if @@error <> 0
				return 1
		end
	end
	else if @cur_version is null and @subscriber_version is not null
	begin
		update dbo.MSmerge_subscriptions
		set subscriber_version = @subscriber_version
		where subid = @subid
	end

	return 0
end

 
Last revision 2008RTM
News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash