-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtriggers.sql
75 lines (61 loc) · 1019 Bytes
/
triggers.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use Negocios
go
select * from sys.triggers --Para ver si tengo al menos 1 trigger
go
create or alter trigger tr_categoria
on compras.categorias
for insert, delete , update
as
begin
print 'Ha realizado una operacion...'
end
go
select * from Compras.categorias
go
------------------
--insert
insert into compras.categorias
values
(777,'Granitos','Granitos Andinos')
go
--update
update compras.categorias
set NombreCategoria='Quinua'
where IdCategoria=777
go
select * from Compras.categorias
go
--Delete
delete from Compras.categorias
where IdCategoria=777
go
-----tablas inserted y deleted---
create or alter trigger tr_cargo
on rrhh.cargos
after insert , update ,delete
as
begin
select * from inserted
select * from deleted
end
go
--
set nocount on
go
--------------
select * from RRHH.Cargos
go
--insert
insert into RRHH.Cargos
values
(10,'Analista de Datos')
go
--update
update RRHH.Cargos
set desCargo='Developer JR'
where idcargo=10
go
--eliminacion
delete from RRHH.Cargos
where idcargo=10
go