Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSscript_trigger_updates

  No additional text.


Syntax
create procedure sys.sp_MSscript_trigger_updates
    @identity_col sysname,
    @ts_col       sysname,
    @op_type      char(3) = 'ins', -- 'ins', 'del'
    @objid        int,
    @indent       int = 0,
    @primary_key_bitmap varbinary(4000) = null
as
    declare @cmd nvarchar(4000)
    declare @col sysname
    declare @qualname nvarchar(517)

    if @op_type = 'upd'
    begin
        -- Script out pk var assigment that used in sp_MSscript_where_clause
        exec sys.sp_MSscript_pkvar_assignment @objid, NULL, 1, @identity_col, @ts_col,
            @primary_key_bitmap

        insert into #proctext(procedure_text) values(N'
    ')
    end

    exec sys.sp_MSget_qualified_name @objid, @qualname OUTPUT

    if @ts_col is not null and OBJECTPROPERTY(@objid, 'tablehastimestamp') <> 1
    begin
        insert into #proctext(procedure_text) values(N'
')
        exec sys.sp_MSpad_command @cmd output, @indent
        exec sys.sp_MSget_col_position @objid, null, @ts_col, @col output
        select @cmd = @cmd + N'update ' + @qualname + N' set ' + @ts_col + N' = @' + @col
        exec sys.sp_MSflush_command @cmd, 1

        exec sys.sp_MSscript_where_clause @objid, null, 'trg pk', null, @indent, @op_type, @primary_key_bitmap
    end

   -- Reset to publisher's identity value if it is not an identity at the subscriber
   if @op_type = 'ins' and @identity_col is not null and OBJECTPROPERTY(@objid, 'tablehasidentity') <> 1
    begin
        insert into #proctext(procedure_text) values(N'
')
        exec sys.sp_MSpad_command @cmd output, @indent
        exec sys.sp_MSget_col_position @objid, null, @identity_col, @col output
        select @cmd = @cmd + N'update ' + @qualname + N' set ' + @identity_col + N' = @' + @col
        exec sys.sp_MSflush_command @cmd, 1

        exec sys.sp_MSscript_where_clause @objid, null, 'trg pk', null, @indent, @op_type, @primary_key_bitmap
    end

 
Last revision 2008RTM
See also

  sp_MSscript_multirow_trigger (Procedure)
sp_MSscript_singlerow_trigger (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