Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSgetpeerlsns

  No additional text.


Syntax
create procedure sys.sp_MSgetpeerlsns
(
	@publication	sysname,
 	@xlockrows 		bit
)
as
begin
	set nocount on

	declare @retcode 	int,
			@dbversion	int
	
	-- security check for subscriber
	exec @retcode = sys.sp_MSreplcheck_subscribe
    if @@error <> 0 or  @retcode <> 0
    begin
        return 1
    end

	-- retrieve the current subscriber database version
	exec @retcode = sys.sp_MSgetdbversion @current_version = @dbversion output
	if @retcode <> 0 or @@error <> 0
	begin
		return 1
	end
	
	-- user wants to place an exclusive lock on the retrieved rows for
	-- the duration of the transaction in which this SP is called...
	if @xlockrows = 1
	begin
		-- note that here we order by pk to ensure lock order
		select distinct	UPPER(originator),
				originator_db,
				originator_publication_id,
				originator_db_version,
				originator_lsn,
				id
			from MSpeer_lsns with (XLOCK, ROWLOCK, INDEX(1))
			where (originator_publication = @publication
						or lower(@publication) = N'all')
					-- and they can not be local water marks or they must be from a differnt db version
					and (UPPER(originator) 			!= UPPER(publishingservername())
						or originator_db 			!= db_name()
						or originator_db_version 	!= @dbversion)
			order by id
		if @@error <> 0
			return 1
	end
	else
	begin
		-- same query as above without the xlock, rowlock hint and no order by
		select distinct	UPPER(originator),
				originator_db,
				originator_publication_id,
				originator_db_version,
				originator_lsn
			from MSpeer_lsns with (INDEX(1))
			where (originator_publication = @publication
						or lower(@publication) = N'all')
					-- and they can not be local water marks or they must be from a differnt db version
					and (UPPER(originator) 			!= UPPER(publishingservername())
						or originator_db 			!= db_name()
						or originator_db_version 	!= @dbversion)
		if @@error <> 0
			return 1
	end

	return 0
end

 
Last revision SQL2008SP2
See also

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