ALTER TABLE [AKUZ].[T_DISPANSERISATION_INIT] ADD [AttendingPost] uniqueidentifier NULL
GO

UPDATE di
SET di.AttendingPost = mr.Post
FROM AKUZ.T_MEDICAL_RECORD mr
JOIN AKUZ.T_DISPANSERISATION_INIT di on mr.MedicalRecordID = di.MedicalRecordID;
GO

ALTER TABLE [AKUZ].[T_DISPANSERISATION_INIT] ALTER COLUMN [AttendingPost] uniqueidentifier NOT NULL
GO

ALTER TABLE [AKUZ].[T_DISPANSERISATION_INIT] ADD CONSTRAINT [FK_T_POST_T_DISPANSERISATION_INIT_AttendingPost]
FOREIGN KEY([AttendingPost]) REFERENCES [AKUZ].[T_POST] ([ResourceID])
GO