create trigger SYM_ON_U_FOR_TM_VNDR_MSSQL on "dbo"."TABLENAME$Item Vendor" with execute as caller after update as begin declare @NCT int set @NCT = @@OPTIONS & 512 set nocount on declare @TransactionId varchar(1000) if (@@TRANCOUNT > 0) begin select @TransactionId = convert(VARCHAR(1000),transaction_id) from sys.dm_exec_requests where session_id=@@SPID and open_transaction_count > 0 end if ("DBNAME".dbo.sym_triggers_disabled() = 0) begin if (1=1 AND ( UPDATE(Vendor No_) OR UPDATE(Item No_) OR UPDATE(Variant Code) ) ) begin insert into "DBNAME"."dbo".sym_data (table_name, event_type, trigger_hist_id, pk_data, channel_id, transaction_id, source_node_id, external_data, create_time) select 'TABLENAME$Item Vendor','D', 37, case when deleted."Vendor No_" is null then '' else '"' + replace(replace(convert(varchar(20),deleted."Vendor No_") ,'\','\\'),'"','\"') + '"' end+','+ case when deleted."Item No_" is null then '' else '"' + replace(replace(convert(varchar(20),deleted."Item No_") ,'\','\\'),'"','\"') + '"' end+','+ case when deleted."Variant Code" is null then '' else '"' + replace(replace(convert(varchar(10),deleted."Variant Code") ,'\','\\'),'"','\"') + '"' end, 'item_vendor', @TransactionId, "DBNAME".dbo.sym_node_disabled(), null, current_timestamp from deleted where 1=1 insert into "DBNAME"."dbo".sym_data (table_name, event_type, trigger_hist_id, row_data, channel_id, transaction_id, source_node_id, external_data, create_time) select 'TABLENAME$Item Vendor','I', 37, case when inserted."Vendor No_" is null then '' else '"' + replace(replace(convert(varchar(20),inserted."Vendor No_") ,'\','\\'),'"','\"') + '"' end+','+ case when inserted."Item No_" is null then '' else '"' + replace(replace(convert(varchar(20),inserted."Item No_") ,'\','\\'),'"','\"') + '"' end+','+ case when inserted."Variant Code" is null then '' else '"' + replace(replace(convert(varchar(10),inserted."Variant Code") ,'\','\\'),'"','\"') + '"' end+','+ case when orig."timestamp" is null then '' else '"' + replace(replace("DBNAME".dbo.sym_base64_encode(CONVERT(VARBINARY(max), orig."timestamp")),'\','\\'),'"','\"') + '"' end+','+ case when inserted."Lead Time Calculation" is null then '' else '"' + replace(replace(convert(varchar(32),inserted."Lead Time Calculation") ,'\','\\'),'"','\"') + '"' end+','+ case when inserted."Vendor Item No_" is null then '' else '"' + replace(replace(convert(varchar(20),inserted."Vendor Item No_") ,'\','\\'),'"','\"') + '"' end+','+ case when inserted."Inventory" is null then '' else ('"' + convert(varchar(40), inserted."Inventory",2) + '"') end+','+ case when inserted."Previous Stock Quantity" is null then '' else ('"' + convert(varchar(40), inserted."Previous Stock Quantity",2) + '"') end+','+ case when inserted."Last Modification Date" is null then '' else ('"' + convert(varchar,inserted."Last Modification Date",121) + '"') end+','+ case when inserted."Preferred supplier" is null then '' else ('"' + convert(varchar(40), inserted."Preferred supplier",2) + '"') end+','+ case when inserted."PPD" is null then '' else ('"' + convert(varchar(40), inserted."PPD",2) + '"') end+','+ case when inserted."Previous PPD" is null then '' else ('"' + convert(varchar(40), inserted."Previous PPD",2) + '"') end+','+ case when inserted."Producer" is null then '' else ('"' + convert(varchar(40), inserted."Producer",2) + '"') end+','+ case when inserted."Status" is null then '' else ('"' + convert(varchar(40), inserted."Status",2) + '"') end, 'item_vendor', @TransactionId, "DBNAME".dbo.sym_node_disabled(), null, current_timestamp from inserted inner join "dbo"."TABLENAME$Item Vendor" orig on orig."Vendor No_"=inserted."Vendor No_" and orig."Item No_"=inserted."Item No_" and orig."Variant Code"=inserted."Variant Code" where 1=1 end else begin insert into "DBNAME"."dbo".sym_data (table_name, event_type, trigger_hist_id, row_data, pk_data, old_data, channel_id, transaction_id, source_node_id, external_data, create_time) select 'TABLENAME$Item Vendor','U', 37, case when inserted."Vendor No_" is null then '' else '"' + replace(replace(convert(varchar(20),inserted."Vendor No_") ,'\','\\'),'"','\"') + '"' end+','+ case when inserted."Item No_" is null then '' else '"' + replace(replace(convert(varchar(20),inserted."Item No_") ,'\','\\'),'"','\"') + '"' end+','+ case when inserted."Variant Code" is null then '' else '"' + replace(replace(convert(varchar(10),inserted."Variant Code") ,'\','\\'),'"','\"') + '"' end+','+ case when orig."timestamp" is null then '' else '"' + replace(replace("DBNAME".dbo.sym_base64_encode(CONVERT(VARBINARY(max), orig."timestamp")),'\','\\'),'"','\"') + '"' end+','+ case when inserted."Lead Time Calculation" is null then '' else '"' + replace(replace(convert(varchar(32),inserted."Lead Time Calculation") ,'\','\\'),'"','\"') + '"' end+','+ case when inserted."Vendor Item No_" is null then '' else '"' + replace(replace(convert(varchar(20),inserted."Vendor Item No_") ,'\','\\'),'"','\"') + '"' end+','+ case when inserted."Inventory" is null then '' else ('"' + convert(varchar(40), inserted."Inventory",2) + '"') end+','+ case when inserted."Previous Stock Quantity" is null then '' else ('"' + convert(varchar(40), inserted."Previous Stock Quantity",2) + '"') end+','+ case when inserted."Last Modification Date" is null then '' else ('"' + convert(varchar,inserted."Last Modification Date",121) + '"') end+','+ case when inserted."Preferred supplier" is null then '' else ('"' + convert(varchar(40), inserted."Preferred supplier",2) + '"') end+','+ case when inserted."PPD" is null then '' else ('"' + convert(varchar(40), inserted."PPD",2) + '"') end+','+ case when inserted."Previous PPD" is null then '' else ('"' + convert(varchar(40), inserted."Previous PPD",2) + '"') end+','+ case when inserted."Producer" is null then '' else ('"' + convert(varchar(40), inserted."Producer",2) + '"') end+','+ case when inserted."Status" is null then '' else ('"' + convert(varchar(40), inserted."Status",2) + '"') end, case when deleted."Vendor No_" is null then '' else '"' + replace(replace(convert(varchar(20),deleted."Vendor No_") ,'\','\\'),'"','\"') + '"' end+','+ case when deleted."Item No_" is null then '' else '"' + replace(replace(convert(varchar(20),deleted."Item No_") ,'\','\\'),'"','\"') + '"' end+','+ case when deleted."Variant Code" is null then '' else '"' + replace(replace(convert(varchar(10),deleted."Variant Code") ,'\','\\'),'"','\"') + '"' end, case when deleted."Vendor No_" is null then '' else '"' + replace(replace(convert(varchar(20),deleted."Vendor No_") ,'\','\\'),'"','\"') + '"' end+','+ case when deleted."Item No_" is null then '' else '"' + replace(replace(convert(varchar(20),deleted."Item No_") ,'\','\\'),'"','\"') + '"' end+','+ case when deleted."Variant Code" is null then '' else '"' + replace(replace(convert(varchar(10),deleted."Variant Code") ,'\','\\'),'"','\"') + '"' end+','+ case when orig."timestamp" is null then '' else '"' + replace(replace("DBNAME".dbo.sym_base64_encode(CONVERT(VARBINARY(max), orig."timestamp")),'\','\\'),'"','\"') + '"' end+','+ case when deleted."Lead Time Calculation" is null then '' else '"' + replace(replace(convert(varchar(32),deleted."Lead Time Calculation") ,'\','\\'),'"','\"') + '"' end+','+ case when deleted."Vendor Item No_" is null then '' else '"' + replace(replace(convert(varchar(20),deleted."Vendor Item No_") ,'\','\\'),'"','\"') + '"' end+','+ case when deleted."Inventory" is null then '' else ('"' + convert(varchar(40), deleted."Inventory",2) + '"') end+','+ case when deleted."Previous Stock Quantity" is null then '' else ('"' + convert(varchar(40), deleted."Previous Stock Quantity",2) + '"') end+','+ case when deleted."Last Modification Date" is null then '' else ('"' + convert(varchar,deleted."Last Modification Date",121) + '"') end+','+ case when deleted."Preferred supplier" is null then '' else ('"' + convert(varchar(40), deleted."Preferred supplier",2) + '"') end+','+ case when deleted."PPD" is null then '' else ('"' + convert(varchar(40), deleted."PPD",2) + '"') end+','+ case when deleted."Previous PPD" is null then '' else ('"' + convert(varchar(40), deleted."Previous PPD",2) + '"') end+','+ case when deleted."Producer" is null then '' else ('"' + convert(varchar(40), deleted."Producer",2) + '"') end+','+ case when deleted."Status" is null then '' else ('"' + convert(varchar(40), deleted."Status",2) + '"') end, 'item_vendor', @TransactionId, "DBNAME".dbo.sym_node_disabled(), null, current_timestamp from inserted inner join "dbo"."TABLENAME$Item Vendor" orig on orig."Vendor No_"=inserted."Vendor No_" and orig."Item No_"=inserted."Item No_" and orig."Variant Code"=inserted."Variant Code" inner join deleted on deleted."Vendor No_"=inserted."Vendor No_" and deleted."Item No_"=inserted."Item No_" and deleted."Variant Code"=inserted."Variant Code" where 1=1 and (1=1) end end if (@NCT = 0) set nocount off end