Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MStran_altertrigger

  No additional text.


Syntax
create procedure sys.sp_MStran_altertrigger
(
	@qual_object_name nvarchar(512) --qualified 2-part-name			
	,@objid	int
	,@pass_through_scripts nvarchar(max)
	,@target_object_name nvarchar(512)
)

AS
	set nocount on

	declare @tran_artid int
			,@retcode int
			,@subscription_active int
			,@include_ddl int
			,@replicate_trigger int
			,@dest_table sysname
			,@dest_owner sysname
			,@qual_dest_object nvarchar(512)
			,@temp_ddlcmds nvarchar(max)

	select @include_ddl = 0x1
		,@subscription_active = 2
		,@retcode = 0
		,@replicate_trigger = 0x100

	begin tran sp_MStran_altertrigger
	save tran sp_MStran_altertrigger
	--loop through relavent publications/articles
	declare #trancolumn CURSOR LOCAL FAST_FORWARD for
		select distinct a.artid, a.dest_table, a.dest_owner
			from sysarticles a
			join sys.objects o on a.objid = o.parent_object_id
			join syspublications p on a.pubid = p.pubid
			join dbo.syssubscriptions s on a.artid = s.artid
			where o.object_id = @objid
					and s.status = @subscription_active
					and (p.replicate_ddl & @include_ddl) = @include_ddl
					and fn_replgetbinary8lodword(a.schema_option) & @replicate_trigger = @replicate_trigger
		
	open #trancolumn
	fetch #trancolumn into @tran_artid, @dest_table, @dest_owner
	while (@@fetch_status <> -1)
	BEGIN
		if(@dest_owner is not NULL) and (len(@dest_owner) > 0)
			select @qual_dest_object = QUOTENAME(@dest_owner) + N'.'
		else
			select @qual_dest_object = N''
		if(@dest_table is not null) and (len(@dest_table) > 0)
			select @qual_dest_object = @qual_dest_object + QUOTENAME(@dest_table)
		else
			select @qual_dest_object = @target_object_name

			select @temp_ddlcmds = N'if object_id(''' +sys.fn_replreplacesinglequote(quotename (object_name(@objid)))+ N''') is not null exec('''
											+ sys.fn_replreplacesinglequote('ALTER TRIGGER '
											+ @qual_object_name + N' on '
											+ @qual_dest_object + N' '
											+ @pass_through_scripts )+ N''')'
			exec @retcode = sys.sp_MStran_autoproc @artid = @tran_artid
	  								,@ddlcmd = @temp_ddlcmds
		if @retcode <>0 or @@ERROR<>0
			goto DROPTRAN
		fetch #trancolumn into @tran_artid, @dest_table, @dest_owner
	END
	close #trancolumn
	deallocate #trancolumn

	commit tran sp_MStran_altertrigger
	return 0

DROPTRAN:
	close #trancolumn
	deallocate #trancolumn

FAILURE:
	rollback tran sp_MStran_altertrigger
	commit tran
	return 1

 
Last revision 2008RTM
See also

  sp_MSdrop_repltran (Procedure)
sp_MStran_ddlrepl (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash