Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSgetbeforetableinsert

  No additional text.


Syntax
create procedure sys.sp_MSgetbeforetableinsert
    @objid int,
    @inscommand nvarchar(2000) output
AS
    declare @before_objid int
    declare @before_name sysname
    declare @collist nvarchar(1000)
    declare @colname sysname
    declare @guidstr nvarchar(36)
    declare @beforeview sysname
    declare @retcode int
    declare @artid uniqueidentifier

    -- Do we have a before table?
    select @before_objid = max(before_image_objid) from  dbo.sysmergearticles where objid = @objid and
            before_image_objid is not null
    select @before_name = OBJECT_NAME(@before_objid)

    if @before_name is null
    begin
        set @inscommand = ''
        return 0
    end

    select @artid = artid from sysmergearticles where objid = @objid
    exec @retcode=sp_MSguidtostr @artid, @guidstr out
    if @retcode<>0 or @@ERROR<>0 return (1)

    set @beforeview = 'MSmerge_bivw_' + @guidstr

    set @collist = ''
    -- Loop over columns to make the column list for the insert / select command
    declare col_cursor CURSOR LOCAL FAST_FORWARD for select name from sys.columns
    where object_id = @before_objid and name <> 'generation' and name <> 'system_delete' order by column_id
    FOR READ ONLY

    open col_cursor

    fetch next from col_cursor into @colname
    while (@@fetch_status <> -1)
    begin
        set @collist = @collist + QUOTENAME(@colname) + ', '
        fetch next from col_cursor into @colname
    end
    close col_cursor
    deallocate col_cursor

    -- Our list has all of the columns except generation since that gets set to a local variable
    -- Make the insert command
    set @inscommand = 'insert into ' + QUOTENAME(@beforeview) + ' ( ' + @collist +
        ' generation) select ' + @collist + ' @newgen from deleted'

    return 0


 
Last revision 2008RTM
See also

  sp_MSaddmergetriggers_internal (Procedure)
sp_MSaddupdatetrigger (Procedure)
sp_MSdrop_rlrecon (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