J'ai une vue partitionnée qui a le déclencheur d'insertion ci-dessous (mauvaise partition mans). Lorsque j'effectue une suppression, j'obtiens le plan de requête ci-dessous:
delete from factproductprice where pricedate = '20170725'
Déclenchement sur la vue:
ALTER TRIGGER [dbo].[factProductPriceDelete] ON [dbo].[FactProductPrice]
INSTEAD OF DELETE AS
BEGIN
IF @@ROWCOUNT = 0 RETURN;
DECLARE @PriceDate DATE
SELECT @PriceDate = CAST(PriceDate AS DATE) FROM DELETED
IF @PriceDate BETWEEN '20140101' AND '20141231'
BEGIN
DELETE FROM dbo.FactProductPrice2014
WHERE ProductId IN (SELECT ProductId FROM DELETED) AND SalesPriceSchemeId IN (SELECT SalesPriceSchemeId FROM DELETED) AND PriceDate IN (SELECT PriceDate FROM DELETED)
END
IF @PriceDate BETWEEN '20150101' AND '20151231'
BEGIN
DELETE FROM dbo.FactProductPrice2015
WHERE ProductId IN (SELECT ProductId FROM DELETED) AND SalesPriceSchemeId IN (SELECT SalesPriceSchemeId FROM DELETED) AND PriceDate IN (SELECT PriceDate FROM DELETED)
END
IF @PriceDate BETWEEN '20160101' AND '20161231'
.... etc