create procedure sys.sp_MSclearcolumnbit
@pubid uniqueidentifier,
@artid uniqueidentifier,
@column_name sysname
as
declare @tablename sysname
declare @colid int
declare @in_use bit
declare @objid int
declare @columns varbinary(128)
declare @local_repid uniqueidentifier
declare @publish int
declare @qual_name nvarchar(517)
set nocount on
set @publish = 0x4000
set @in_use=0
set @local_repid = NULL
-- Security Checking
-- sysadmin or db_owner or replication agent have access
if ({fn ISPALUSER(@pubid)} <> 1)
if is_member ('db_ddladmin') <>1
begin
raiserror(14260, 16, -1)
return (1)
end
select @tablename = object_name(objid), @objid=objid from dbo.sysmergearticles where artid=@artid and pubid=@pubid
select @colid=column_id from sys.columns where object_id=@objid and name=@column_name
select top 1 @local_repid=pubid from dbo.sysmergearticles where artid=@artid and pubid<>@pubid order by pubid ASC
begin tran
save tran sp_MSclearcolumnbit
-- Acquire exclusive lock for subsequent system object updates
exec sys.sp_MSget_qualified_name @objid, @qual_name OUTPUT
exec %%Object(MultiName=@qual_name).LockMatchID(ID=@objid, Exclusive = 1, BindInternal = 0)
--exec %%Object(MultiName=@qual_name).LockExclusiveMatchID(ID=@objid)
if @@error<>0
goto FAILURE
if @local_repid is NULL
begin
exec %%ColumnEx(ObjectID=@objid,Name=@column_name).SetMergePublished(Value=0)
if @@ERROR<>0
goto FAILURE
commit tran
return (0)
end
while @local_repid is not NULL and @in_use=0
begin
select @columns = columns from dbo.sysmergearticles where pubid=@local_repid and artid=@artid
exec @in_use = sys.sp_MStestbit @bm=@columns, @coltotest=@colid
set @local_repid = NULL
select top 1 @local_repid=pubid from dbo.sysmergearticles where artid=@artid and pubid>@local_repid order by pubid ASC
end
if @in_use=0
begin
exec %%ColumnEx(ObjectID=@objid,Name=@column_name).SetMergePublished(Value=0)
if @@ERROR<>0
goto FAILURE
end
commit tran
return (0)
FAILURE:
rollback tran sp_MSclearcolumnbit
commit tran
return (1)