IF  EXISTS (SELECT * 
            FROM   dbo.sysobjects 
            WHERE  id = OBJECT_ID(N'[dbo].[sp_SyncMedicalExamination]') AND xtype = N'P')
DROP PROCEDURE [dbo].[sp_SyncMedicalExamination]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:  Michael Panin
-- Create date: 2023/08/08
-- Description: Обновление ссылок на DOCTOR_WARD_EXAMINATION
-- =============================================

CREATE PROCEDURE [dbo].[sp_SyncMedicalExamination]
    @newDweId uniqueidentifier, -- Идентификатор нового DOCTOR_WARD_EXAMINATION
    @oldDweId uniqueidentifier  -- Идентификатор старого DOCTOR_WARD_EXAMINATION
AS 
BEGIN

UPDATE AKUZ.T_MEDICAL_EXAMINATION_RE
SET    MedicalExaminationMain = @newDweId
WHERE  MedicalExaminationMain = @oldDweId;

END
GO
