IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_DeleteCancelledDestinations]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[sp_DeleteCancelledDestinations]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:      Vitacore (с) Mokin Mikhail
-- Create date: 2024 03 24
-- Description: Удаление отменённых назначений
-- =============================================
CREATE PROCEDURE [dbo].[sp_DeleteCancelledDestinations]
    @DateToDelete datetime
AS
BEGIN
	update AKUZ.T_MOVEMENTS_DIVISION_CARD
	set AKUZ.T_MOVEMENTS_DIVISION_CARD.CancelledDestinations = null
	where RealDateOut <= @DateToDelete and CancelledDestinations is not null
END


