Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSIfExistsSubscription

  No additional text.


Syntax
create procedure sys.sp_MSIfExistsSubscription
(
    @publisher sysname,
    @publisher_db sysname,
    @publication sysname,
    @type int /* replication type, 1 - transactional/snapshot, 2 - merge */
)
as
begin
    declare @publisher_id smallint
    declare @publication_id int

    
    -- security check
    -- only replmonitor can execute this
    
    if not (is_member(N'db_owner') = 1 or isnull(is_member(N'replmonitor'),0) = 1)
    begin
        raiserror(14260, 16, -1)
        return (1)
    end

    if @type not in (1,2)
    begin
        RAISERROR(21055, 16, -1, '@type','sp_MSIfExistsSubscription')
        RETURN (1)
    end

    set nocount on

    select @publisher_id = srvid from master.dbo.sysservers where
       UPPER(srvname) = UPPER(@publisher)

	if @type = 1
	begin
		select @publication_id = publication_id from dbo.MSpublications  where
				publisher_id = @publisher_id and
				publisher_db = @publisher_db and
				publication = @publication and
				(publication_type = 0 or publication_type = 1)

		select TOP 1 1 from MSdistribution_agents a
			where exists (select * from dbo.MSsubscriptions s where
				(a.id = s.agent_id or a.anonymous_agent_id = s.agent_id) and
				s.publisher_id = @publisher_id and
				s.publisher_db = @publisher_db and
				-- For 6.x publisher, we don't know the association between the publication
				-- and subscriptions. Show every dist agent under each publication.
				(s.publication_id = @publication_id or s.publication_id = 0 ) and
				(a.subscriber_id >= 0  or a.subscriber_id is NULL))
	end
	else
	begin
		select @publication_id = publication_id from dbo.MSpublications  where
				publisher_id = @publisher_id and
				publisher_db = @publisher_db and
				publication = @publication and
				publication_type = 2 -- Merge

		select TOP 1 1 from dbo.MSmerge_agents
			where publisher_id = @publisher_id and
				publisher_db = @publisher_db and
				publication = @publication
	end
end

 
Last revision 2008RTM
See also

  sp_instdist (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