-- Tables

/***** Object:  Table [AKUZ].[T_REHABILITATION_TECHNOLOGY_DICTIONARY_LINK] *****/
CREATE TABLE [AKUZ].[T_REHABILITATION_TECHNOLOGY_DICTIONARY_LINK]
(
    [RehabilitationTechnologyDictionaryLinkID] uniqueidentifier NOT NULL,
    [RehabilitationTechnologyDictionary] uniqueidentifier NULL,
    [RehabilitationTask] uniqueidentifier NULL
)
ON [PRIMARY]
GO

-- Alters

ALTER TABLE [AKUZ].[T_REHABILITATION_TECHNOLOGY_DICTIONARY_LINK] ADD CONSTRAINT [PK_T_REHABILITATION_TECHNOLOGY_DICTIONARY_LINK]
PRIMARY KEY CLUSTERED ([RehabilitationTechnologyDictionaryLinkID]) ON [PRIMARY]
GO

ALTER TABLE [AKUZ].[T_REHABILITATION_TECHNOLOGY_DICTIONARY_LINK] ADD CONSTRAINT [FK_T_REHABILITATION_TECHNOLOGY_DICTIONARY_T_REHABILITATION_TECHNOLOGY_DICTIONARY_LINK_RehabilitationTechnologyDictionary]
FOREIGN KEY([RehabilitationTechnologyDictionary]) REFERENCES [AKUZ].[T_REHABILITATION_TECHNOLOGY_DICTIONARY] ([RehabilitationTechnologyDictionaryID])
GO

ALTER TABLE [AKUZ].[T_REHABILITATION_TECHNOLOGY_DICTIONARY_LINK] ADD CONSTRAINT [FK_T_REHABILITATION_TASK_T_REHABILITATION_TECHNOLOGY_DICTIONARY_LINK_RehabilitationTask]
FOREIGN KEY([RehabilitationTask]) REFERENCES [AKUZ].[T_REHABILITATION_TASK] ([MkfDiagnosisRecordID])
GO

INSERT INTO AKUZ.T_REHABILITATION_TECHNOLOGY_DICTIONARY_LINK (RehabilitationTechnologyDictionaryLinkID, RehabilitationTechnologyDictionary, RehabilitationTask)  
SELECT  newid() , RehabilitationTechnologyDictionary, MkfDiagnosisRecordID
  FROM AKUZ.T_REHABILITATION_TASK

ALTER TABLE [AKUZ].[T_REHABILITATION_TASK] DROP CONSTRAINT [FK_T_REHABILITATION_TECHNOLOGY_DICTIONARY_T_REHABILITATION_TASK_RehabilitationTechnologyDictionary]
GO

ALTER TABLE [AKUZ].[T_REHABILITATION_TASK] DROP COLUMN [RehabilitationTechnologyDictionary]
GO





