-- Tables

-- Alters

ALTER TABLE [AKUZ].[T_ASSOCIATED_DISEASE] ADD [TypeDisease] int NULL
GO
UPDATE [AKUZ].[T_ASSOCIATED_DISEASE] SET [TypeDisease] = 0
GO
ALTER TABLE [AKUZ].[T_ASSOCIATED_DISEASE] ALTER COLUMN [TypeDisease] int NOT NULL
GO

INSERT INTO [AKUZ].[T_ASSOCIATED_DISEASE] (MedicalExamination, AssociatedDiseaseID, Mkb, Diagnosis, TypeDisease) 
									SELECT me.MedicalRecordID, NEWID(), me.ComplicationMkb, me.ComplicationDiagnosis, 1
									FROM AKUZ.T_MEDICAL_EXAMINATION me
									WHERE me.ComplicationMkb is NOT NULL And me.ComplicationDiagnosis is NOT NULL
GO

ALTER TABLE AKUZ.T_MEDICAL_EXAMINATION DROP COLUMN ComplicationMkb, ComplicationDiagnosis
GO