Home Microsoft SQL Server DigiMailing iRN Contact


  No additional text.

create procedure sys.sp_MScreatedownloadonlytriggers
    @artid    uniqueidentifier
    declare @objid int
    declare @cmd nvarchar(max)
    declare @qualified_tablename nvarchar(270)
    declare @ownername nvarchar(130)
    declare @tablename nvarchar(130)
    declare @triggername nvarchar(130)
    declare @guidstr nchar(32)
    declare @retcode int
    declare @upload_options    tinyint

    select top 1 @objid= objid, @ownername= destination_owner, @tablename= destination_object,
        @upload_options= upload_options
        from dbo.sysmergearticles where artid = @artid

    if @objid is null return 1

    exec @retcode=sys.sp_MSguidtostr @artid, @guidstr out
    if @retcode <> 0 or @@error <> 0 return (1)

    -- remove download-only trigger, if it exists
    set @triggername= 'MSmerge_downloadonly_' + @guidstr
    set @cmd= 'if object_id(''' + @triggername + ''', ''TR'') is not null
                    drop trigger [' + @triggername + ']'
    exec sys.sp_executesql @cmd
    if @@error <> 0 return 1

    -- Do not generate the trigger to block dml unless the upload_options is set to 'disable_uploads_prohibit_subscriber_changes' (2)

    if @upload_options <> 2
        return 0

    if @ownername is not null
        set @qualified_tablename= quotename(@ownername) + '.' + quotename(@tablename)
        set @qualified_tablename= quotename(@tablename)

    set @triggername = 'MSmerge_downloadonly_' + @guidstr

    set @cmd='
    create trigger ' + @triggername + ' on ' + @qualified_tablename + ' for update, insert, delete
        not for replication
         set nocount on

        if @@trancount > 0 rollback tran
        raiserror (20063, 16, -1, ''' + sys.fn_replreplacesinglequote(@qualified_tablename) + ''')


    exec sys.sp_executesql @cmd
    if @@error <> 0 return 1

    return 0

Last revision 2008RTM
See also

  sp_MSaddmergetriggers (Procedure)
sp_MScreatelightweightprocstriggersconstraints (Procedure)
sp_MSdrop_rlcore (Procedure)


  Query a named instance
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
Zoekmachine optimalisatie
SQL Servers hidden objects
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
sIFR; de combinatie tussen HTML en Flash