IF EXISTS (SELECT name FROM sysobjects WHERE name = 'tsiDavekLog' AND type = 'TR') DROP TRIGGER tsiDavekLog go CREATE TRIGGER tsiDavekLog ON tsiDavek FOR UPDATE, DELETE, INSERT NOT FOR REPLICATION AS -- Mp 18.10.2006 Beleži spremembe tabele tsiDavek Declare @TableName varchar(50) Declare @PKName varchar(50) Declare @CurrentUser nVarChar(20) Declare @UpdateDate datetime Declare @Workstation Varchar(50) Declare @sAction VarChar(10) Select @TableName= 'tsiDavek' Select @PKName= 'Zaporedje' Select @CurrentUser = system_user Select @UpdateDate = convert(varchar(8), getdate(), 112) + ' ' + convert(varchar(8), getdate(), 108) Select @Workstation = host_name() IF @@RowCount <> 1 Return SET NoCount On IF EXISTS(SELECT * FROM inserted) AND EXISTS(SELECT * FROM deleted) SET @sAction = 'UPDATE' ELSE IF EXISTS(SELECT * FROM inserted) SET @sAction = 'INSERT' ELSE SET @sAction = 'DELETE' If @sAction = 'INSERT' Begin INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'DavekIDP', NULL, Inserted.DavekIDP FROM INSERTED WHERE Inserted.DavekIDP Is Not Null INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'DavekID', NULL, Inserted.DavekID FROM INSERTED WHERE Inserted.DavekID Is Not Null INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'Tarifa', NULL, Inserted.Tarifa FROM INSERTED WHERE Inserted.Tarifa Is Not Null INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'DavekNaziv', NULL, Inserted.DavekNaziv FROM INSERTED WHERE Inserted.DavekNaziv Is Not Null INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'DavekNazivIzpis', NULL, Inserted.DavekNazivIzpis FROM INSERTED WHERE Inserted.DavekNazivIzpis Is Not Null INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'DavekKlavzula', NULL, Inserted.DavekKlavzula FROM INSERTED WHERE Inserted.DavekKlavzula Is Not Null INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'Procent', NULL, CAST(Inserted.Procent AS nVarChar(255)) FROM INSERTED WHERE Inserted.Procent Is Not Null INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'PreracunanProcent', NULL, CAST(Inserted.PreracunanProcent AS nVarChar(255)) FROM INSERTED WHERE Inserted.PreracunanProcent Is Not Null INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'Znesek', NULL, CAST(Inserted.Znesek AS nVarChar(255)) FROM INSERTED WHERE Inserted.Znesek Is Not Null INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'Oprostitev', NULL, Inserted.Oprostitev FROM INSERTED WHERE Inserted.Oprostitev Is Not Null INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'KontoIDP', NULL, Inserted.KontoIDP FROM INSERTED WHERE Inserted.KontoIDP Is Not Null INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'KontoID', NULL, Inserted.KontoID FROM INSERTED WHERE Inserted.KontoID Is Not Null INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'KontoKpID', NULL, Inserted.KontoKpID FROM INSERTED WHERE Inserted.KontoKpID Is Not Null INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'Zaporedje', NULL, Inserted.Zaporedje FROM INSERTED WHERE Inserted.Zaporedje Is Not Null INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'StatusDDV', NULL, Inserted.StatusDDV FROM INSERTED WHERE Inserted.StatusDDV Is Not Null INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'VdIDP', NULL, Inserted.VdIDP FROM INSERTED WHERE Inserted.VdIDP Is Not Null INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Insert', @PKName, Inserted.Zaporedje, 'VdID', NULL, Inserted.VdID FROM INSERTED WHERE Inserted.VdID Is Not Null End If @sAction = 'UPDATE' Begin INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'DavekIDP', Deleted.DavekIDP, Inserted.DavekIDP FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.DavekIDP, '')<>IsNull(Inserted.DavekIDP, '') INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'DavekID', Deleted.DavekID, Inserted.DavekID FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.DavekID, '')<>IsNull(Inserted.DavekID, '') INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'Tarifa', Deleted.Tarifa, Inserted.Tarifa FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.Tarifa, '')<>IsNull(Inserted.Tarifa, '') INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'DavekNaziv', Deleted.DavekNaziv, Inserted.DavekNaziv FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.DavekNaziv, '')<>IsNull(Inserted.DavekNaziv, '') INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'DavekNazivIzpis', Deleted.DavekNazivIzpis, Inserted.DavekNazivIzpis FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.DavekNazivIzpis, '')<>IsNull(Inserted.DavekNazivIzpis, '') INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'DavekKlavzula', Deleted.DavekKlavzula, Inserted.DavekKlavzula FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.DavekKlavzula, '')<>IsNull(Inserted.DavekKlavzula, '') INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'Procent', CAST(Deleted.Procent AS nVarChar(255)), CAST(Inserted.Procent AS nVarChar(255)) FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.Procent, 0)<>IsNull(Inserted.Procent, 0) INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'PreracunanProcent', CAST(Deleted.PreracunanProcent AS nVarChar(255)), CAST(Inserted.PreracunanProcent AS nVarChar(255)) FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.PreracunanProcent, 0)<>IsNull(Inserted.PreracunanProcent, 0) INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'Znesek', CAST(Deleted.Znesek AS nVarChar(255)), CAST(Inserted.Znesek AS nVarChar(255)) FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.Znesek, 0)<>IsNull(Inserted.Znesek, 0) INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'Oprostitev', Deleted.Oprostitev, Inserted.Oprostitev FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.Oprostitev, '')<>IsNull(Inserted.Oprostitev, '') INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'KontoIDP', Deleted.KontoIDP, Inserted.KontoIDP FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.KontoIDP, '')<>IsNull(Inserted.KontoIDP, '') INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'KontoID', Deleted.KontoID, Inserted.KontoID FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.KontoID, '')<>IsNull(Inserted.KontoID, '') INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'KontoKpID', Deleted.KontoKpID, Inserted.KontoKpID FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.KontoKpID, '')<>IsNull(Inserted.KontoKpID, '') INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'Zaporedje', Deleted.Zaporedje, Inserted.Zaporedje FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.Zaporedje, '')<>IsNull(Inserted.Zaporedje, '') INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'StatusDDV', Deleted.StatusDDV, Inserted.StatusDDV FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.StatusDDV, '')<>IsNull(Inserted.StatusDDV, '') INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'VdIDP', Deleted.VdIDP, Inserted.VdIDP FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.VdIDP, '')<>IsNull(Inserted.VdIDP, '') INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName,'Update', @PKName, Inserted.Zaporedje, 'VdID', Deleted.VdID, Inserted.VdID FROM INSERTED INNER JOIN DELETED ON INSERTED.Zaporedje=DELETED.Zaporedje WHERE IsNull(Deleted.VdID, '')<>IsNull(Inserted.VdID, '') End If @sAction = 'DELETE' Begin INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'DavekIDP', Deleted.DavekIDP, Null FROM DELETED INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'DavekID', Deleted.DavekID, Null FROM DELETED INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'Tarifa', Deleted.Tarifa, Null FROM DELETED INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'DavekNaziv', Deleted.DavekNaziv, Null FROM DELETED INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'DavekNazivIzpis', Deleted.DavekNazivIzpis, Null FROM DELETED INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'DavekKlavzula', Deleted.DavekKlavzula, Null FROM DELETED INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'Procent', CAST(Deleted.Procent AS nVarChar(255)), Null FROM DELETED INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'PreracunanProcent', CAST(Deleted.PreracunanProcent AS nVarChar(255)), Null FROM DELETED INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'Znesek', CAST(Deleted.Znesek AS nVarChar(255)), Null FROM DELETED INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'Oprostitev', Deleted.Oprostitev, Null FROM DELETED INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'KontoIDP', Deleted.KontoIDP, Null FROM DELETED INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'KontoID', Deleted.KontoID, Null FROM DELETED INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'KontoKpID', Deleted.KontoKpID, Null FROM DELETED INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'Zaporedje', Deleted.Zaporedje, Null FROM DELETED INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'StatusDDV', Deleted.StatusDDV, Null FROM DELETED INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'VdIDP', Deleted.VdIDP, Null FROM DELETED INSERT INTO tfsTabelaLog (recDateTime, WorkstationID, CurrentUser, TableName, TableAction, recIDField, recID, FieldName, OldValue, NewValue) SELECT @UpdateDate, @Workstation, @CurrentUser, @TableName, 'Delete', @PKName, Deleted.Zaporedje, 'VdID', Deleted.VdID, Null FROM DELETED End