/*
** We need to qualify sysmergearticle with pubid
*/
create procedure sys.sp_MSdroparticletriggers
(@source_table sysname,
@table_owner sysname = NULL)
as
set nocount on
declare @instrigger nvarchar(517)
declare @updtrigger nvarchar(517)
declare @deltrigger nvarchar(517)
declare @downloadonlytrigger nvarchar(517)
declare @retcode int
declare @owner sysname
declare @artid uniqueidentifier
declare @guidstr nvarchar(32)
declare @islightweight bit
declare @qualified_name nvarchar(517)
declare @objid int
set @owner= coalesce(@table_owner, 'dbo')
set @qualified_name= quotename(@owner) + '.' + quotename(@source_table)
set @objid= object_id(@qualified_name)
-- Check whether the table is hws or lws, return success if it is neither.
select top 1 @islightweight= lightweight, @artid= artid
from dbo.sysmergearticles
where objid=@objid
if @islightweight is null return 0
if 0=@islightweight
begin
exec @retcode=sys.sp_MSguidtostr @artid, @guidstr out
if @retcode<>0 or @@ERROR<>0 return (1)
select @instrigger = QUOTENAME(@owner) + '.MSmerge_ins_' + @guidstr
select @updtrigger = QUOTENAME(@owner) + '.MSmerge_upd_' + @guidstr
select @deltrigger = QUOTENAME(@owner) + '.MSmerge_del_' + @guidstr
select @downloadonlytrigger = QUOTENAME(@owner) + '.MSmerge_downloadonly_' + @guidstr
if object_id(@instrigger) is not NULL
begin
exec ('drop trigger ' + @instrigger)
if @@ERROR<>0 return (1)
end
if object_id(@updtrigger) is not NULL
begin
exec ('drop trigger ' + @updtrigger)
if @@ERROR<>0 return (1)
end
if object_id(@deltrigger) IS NOT NULL
begin
exec ('drop trigger ' + @deltrigger)
if @@ERROR<>0 return (1)
end
if object_id(@downloadonlytrigger) IS NOT NULL
begin
exec ('drop trigger ' + @downloadonlytrigger)
if @@ERROR<>0 return (1)
end
end -- 0=@islightweight
else
begin
exec @retcode= sys.sp_MSdroplightweighttriggers @artid=@artid
if @@error<>0 or @retcode<>0 return 1
end
return 0