ALTER TABLE akuz.t_inability
    ADD post INT NULL
GO

UPDATE i
SET
    i.post       = mr.post
FROM akuz.t_inability i
JOIN akuz.t_medical_record mr ON mr.medicalrecordid = i.medicalrecordid;
GO

ALTER TABLE akuz.t_inability
    DROP CONSTRAINT fk_t_inability_t_medical_record;
GO

DELETE mr
FROM akuz.t_medical_record mr
JOIN akuz.t_inability cte ON mr.medicalrecordid = cte.medicalrecordid
GO

ALTER TABLE [AKUZ].[T_INABILITY]
    ADD CONSTRAINT [FK_T_POST_T_INABILITY_Post]
        FOREIGN KEY ([Post]) REFERENCES [AKUZ].[T_POST] ([ResourceID])
GO

ALTER TABLE akuz.t_inability
    ALTER COLUMN post INT NOT NULL
GO

