create procedure sys.sp_MSscript_trigger_version_updates
(
@objid int,
@version_col sysname,
@indent int = 0,
@primary_key_bitmap varbinary(4000)
)
as
begin
set nocount on
declare @cmd nvarchar(4000)
,@col sysname
,@qualname nvarchar(517)
-- Script out pk var assigment that used in sp_MSscript_where_clause
exec sys.sp_MSscript_pkvar_assignment @objid, NULL, 1, null, null, @primary_key_bitmap
-- Assign the param corresponding to version col to new guid
exec sys.sp_MSget_col_position @objid, null, @version_col, @col output
exec sys.sp_MSget_qualified_name @objid, @qualname OUTPUT
select @cmd = N'
if not update (msrepl_tran_version)
begin
select @' + @col + N' = @version_guid
update ' + @qualname + N' set ' + @version_col + N' = @' + @col + N' '
insert into #proctext(procedure_text) values(@cmd)
exec sys.sp_MSscript_where_clause @objid, null, 'trg pk', null, 0, 'upd', @primary_key_bitmap
select @cmd = N'
end'
insert into #proctext(procedure_text) values(@cmd)
-- all done
return 0
end