create procedure sys.sp_MScheckcontext_bypasswholeddleventbit @is_biton bit output
as
begin
declare @cur_context varbinary(128)
declare @cur_context_first_byte binary(1)
declare @returnbitmask tinyint
select @returnbitmask = 64
-- get the current context_info.
select @cur_context = isnull(context_info(),0x00)
-- get the first byte out of the 128 byte array.
select @cur_context_first_byte = substring(@cur_context, 1, 1)
-- check whether it has the merge agent bit set.
select @returnbitmask = (convert(tinyint,@cur_context_first_byte) & @returnbitmask)
-- set the output param value appropriately.
select @is_biton = case when @returnbitmask = 0 then 0 else 1 end
return 0
end