create procedure sys.sp_MSmerge_validate_publication_presence (
@publication sysname,
@dbname sysname,
@servername sysname,
@pubid uniqueidentifier output
) AS
if (@publication is null)
begin
RAISERROR(14043, 16, -1, '@publication', 'sp_MSmerge_validate_publication_presence')
return (1)
end
if @dbname is NULL
select @dbname = db_name()
if @servername is NULL
select @servername = @@servername
/* If the database is being mirrored, then compare the publisher to @servername and to the partner server name */
declare @mirroring_partner_instance sysname
set @mirroring_partner_instance = NULL
select @mirroring_partner_instance = mirroring_partner_instance from sys.database_mirroring where database_id = db_id(@dbname)
if @mirroring_partner_instance is not NULL
begin
select @pubid = pubid from dbo.sysmergepublications where name = @publication and (upper(publisher) = upper(@@servername) or (upper(publisher) = upper(@mirroring_partner_instance))) and publisher_db = @dbname
end
else
begin
select @pubid = pubid from dbo.sysmergepublications where name = @publication and upper(publisher) = upper(@servername) and publisher_db = @dbname
end
if @pubid is NULL
begin
if (is_member('db_owner') = 1)
begin
RAISERROR (20026, 16, -1, @publication)
RETURN (1)
end
else
begin
RAISERROR (21423, 16, -1, @publication)
RETURN (1)
end
end
if {fn ISPALUSER(@pubid)} <> 1
begin
RAISERROR (21423, 16, -1, @publication)
RETURN (1)
end