Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSispeertopeeragent

  No additional text.


Syntax
create procedure sys.sp_MSispeertopeeragent
(
	@agent_id 	int,
	@is_p2p		int output
)
as
begin
	set nocount on
	
	declare @retcode 			tinyint,
			@publisher_db 		sysname,
			@publisher_id 		int,
			@publication 		sysname,
			@num_p2p_pubs int

    declare @OPT_ENABLED_FOR_P2P int

	select @OPT_ENABLED_FOR_P2P = 0x1

	-- security check - the distribution agent must have access
	exec @retcode = sp_MScheck_pull_access @agent_id = @agent_id, @agent_type = 0
	if @@error <> 0 or @retcode <> 0
	begin
		return 1
	end
	
	-- Has to be executed from distribution database
	if sys.fn_MSrepl_isdistdb (db_name()) != 1
	begin
		-- sp_MSispeertopeeragent can only be executed in the distribution database.
		raiserror (21482, 16, -1, 'sp_MSispeertopeeragent', 'distribution')
		return 1
	end

   	select @publisher_db 	= publisher_db,
	        @publisher_id 	= publisher_id,
	        @publication 	= publication
        from MSdistribution_agents
        where id = @agent_id

    -- find out if there are any PeerToPeer publications for this agent
    if lower(@publication) = 'all'
	begin
		--shared agent (one agent for all publications that go to a single subscriber)
		--Get all the subscriptions for this agent, then find out all the publications
		select @num_p2p_pubs = count(*)
			from dbo.MSsubscriptions mss
				inner join dbo.MSpublications msp
					on mss.publisher_id 		= msp.publisher_id
						and mss.publisher_db 	= msp.publisher_db
						and mss.publication_id 	= msp.publication_id
			where mss.agent_id = @agent_id
				and (msp.options & @OPT_ENABLED_FOR_P2P) = @OPT_ENABLED_FOR_P2P
	end
    else
	begin
		--independent agent (one agent for each publication)
		select @num_p2p_pubs = count(*)
			from dbo.MSpublications msp
			where msp.publication 		= @publication
				and	msp.publisher_db 	= @publisher_db
				and msp.publisher_id 	= @publisher_id
				and (msp.options & @OPT_ENABLED_FOR_P2P) = @OPT_ENABLED_FOR_P2P
	end

	if @num_p2p_pubs > 0
		select @is_p2p = 1
	else
		select @is_p2p = 0

	return 0
end

 
Last revision 2008RTM
See also

  sp_MSdelete_tracer_history (Procedure)
sp_MSget_min_seqno (Procedure)
sp_MSget_repl_commands (Procedure)
sp_MShelptracertokenhistory (Procedure)
sp_MShelptracertokens (Procedure)
sp_MSsubscription_status (Procedure)
       



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