1 2 3 4 5 6 7 8 9 10 11 12
| ALTER TRIGGER [dbo].[Trig_view_histo] ON [dbo].[histo] INSTEAD OF INSERT AS BEGIN
SET NOCOUNT ON
INSERT INTO histo_2013.dbo.histo (id,date,value) SELECT id,date,value from inserted where year(date) = 2013 and id is not null
INSERT INTO histo_2014.dbo.histo (id,date,value) SELECT id,date,value from inserted where year(date) = 2014 and id is not null
INSERT INTO histo_2015.dbo.histo (id,date,value) SELECT id,date,value from inserted where year(date) = 2015 and id is not null
INSERT INTO histo_2016.dbo.histo (id,date,value) SELECT id,date,value from inserted where year(date) = 2016 and id is not null
INSERT INTO histo_2017.dbo.histo (id,date,value) SELECT id,date,value from inserted where year(date) = 2017 and id is not null
INSERT INTO histo_2018.dbo.histo (id,date,value) SELECT id,date,value from inserted where year(date) = 2018 and id is not null
INSERT INTO histo_2019.dbo.histo (id,date,value) SELECT id,date,value from inserted where year(date) = 2019 and id is not null
INSERT INTO histo_2020.dbo.histo (id,date,value) SELECT id,date,value from inserted where year(date) = 2020 and id is not null
INSERT INTO histo_2021.dbo.histo (id,date,value) SELECT id,date,value from inserted where year(date) = 2021 and id is not null
END |
Partager