Skip to content

Instantly share code, notes, and snippets.

@viniciusgati
Created December 13, 2019 19:00
Show Gist options
  • Save viniciusgati/9b1c747d42de4ec8a7a576829c8cbdd0 to your computer and use it in GitHub Desktop.
Save viniciusgati/9b1c747d42de4ec8a7a576829c8cbdd0 to your computer and use it in GitHub Desktop.
drop table if exists log_sc7
go
create table log_sc7 (
id bigint identity primary key,
usuario_alterou varchar(250) not null,
numero_pedido varchar(250) not null,
grupo_compra_antes varchar(250) not null,
grupo_compra_depois varchar(250) not null,
data_alterado datetime not null,
)
go
create TRIGGER [dbo].[tr_log_sc7] ON [dbo].[SC7990]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;
IF UPDATE (C7_CONAPRO)
BEGIN
insert into log_sc7 (grupo_compra_antes, grupo_compra_depois,numero_pedido, usuario_alterou, data_alterado) values
(
(select top 1 C7_GRUPCOM from deleted),
(select top 1 C7_GRUPCOM from inserted),
(select top 1 C7_NUM from inserted),
(select top 1 C7_USER from inserted),
GETDATE())
END
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment