create procedure sys.sp_isarticlecolbitset
(
@colid int
,@artid int
,@publishertype tinyint=1 -- 1 = mssqlserver, 2 = heterogeneous
,@agent_id int = NULL -- null @agent_id means this is executed at pub side,
-- pub queries sysarticlecolumns for article column partition,
-- sub uses MSsubscription_articlecolumns
)
as
begin
declare @retcode int
,@pubtypemssqlserver tinyint
,@pubtypeheterogenous tinyint
-- initialize
select @retcode = 0
,@pubtypemssqlserver = 1
,@pubtypeheterogenous = 2
-- process based on publisher type
if (@publishertype = @pubtypemssqlserver)
begin
-- mssqlserver publisher
if (@agent_id is null)
begin
if exists (select artid from dbo.sysarticlecolumns where artid = @artid and colid = @colid)
select @retcode = 1
end
else
begin
if exists (select artid from dbo.MSsubscription_articlecolumns where artid = @artid and colid = @colid
and agent_id = @agent_id)
select @retcode = 1
end
end
else if (@publishertype = @pubtypeheterogenous)
begin
-- heterogeneous publisher
if exists (select article_id from IHcolumns where article_id = @artid and column_id = @colid)
select @retcode = 1
end
else
begin
raiserror(21402, 16, 14, '@publishertype')
end
-- return
return @retcode
end