IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[AKUZ].[T_CDA_IDENTIFICATION_DOCUMENT_ROUTTODIAG]') AND name = N'UQ_T_CDA_IDENTIFICATION_DOCUMENT_ROUTTODIAG_CdaRepresentativeRouttodiag' and is_unique_constraint <> 1)
DROP INDEX [UQ_T_CDA_IDENTIFICATION_DOCUMENT_ROUTTODIAG_CdaRepresentativeRouttodiag] ON [AKUZ].[T_CDA_IDENTIFICATION_DOCUMENT_ROUTTODIAG]
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[AKUZ].[T_CDA_IDENTIFICATION_DOCUMENT_ROUTTODIAG]') AND name = N'UQ_T_CDA_IDENTIFICATION_DOCUMENT_ROUTTODIAG_CdaRepresentativeRouttodiag' and is_unique_constraint = 1)
ALTER TABLE [AKUZ].[T_CDA_IDENTIFICATION_DOCUMENT_ROUTTODIAG] DROP CONSTRAINT [UQ_T_CDA_IDENTIFICATION_DOCUMENT_ROUTTODIAG_CdaRepresentativeRouttodiag]
IF  EXISTS (SELECT * FROM sys.columns WHERE object_id = OBJECT_ID(N'[AKUZ].[T_CDA_IDENTIFICATION_DOCUMENT_ROUTTODIAG]') AND name = N'CdaRepresentativeRouttodiag_UQ')
ALTER TABLE [AKUZ].[T_CDA_IDENTIFICATION_DOCUMENT_ROUTTODIAG] DROP COLUMN [CdaRepresentativeRouttodiag_UQ]
GO

ALTER TABLE [AKUZ].[T_CDA_AUTHORITY_DOC_ROUTTODIAG] DROP CONSTRAINT [FK_T_CDA_REPRESENTATIVE_ROUTTODIAG_T_CDA_AUTHORITY_DOC_ROUTTODIAG_CdaRepresentativeRouttodiag]
GO

ALTER TABLE [AKUZ].[T_CDA_CONTACT_ROUTTODIAG] DROP CONSTRAINT [FK_T_CDA_REPRESENTATIVE_ROUTTODIAG_T_CDA_CONTACT_ROUTTODIAG_CdaRepresentativeRouttodiag]
GO

ALTER TABLE [AKUZ].[T_CDA_IDENTIFICATION_DOCUMENT_ROUTTODIAG] DROP CONSTRAINT [FK_T_CDA_REPRESENTATIVE_ROUTTODIAG_T_CDA_IDENTIFICATION_DOCUMENT_ROUTTODIAG_CdaRepresentativeRouttodiag]
GO

DROP TABLE AKUZ.T_CDA_REPRESENTATIVE_ROUTTODIAG
GO

UPDATE AKUZ.T_CDA_AUTHORITY_DOC_ROUTTODIAG
SET CdaRepresentativeRouttodiag = null

UPDATE AKUZ.T_CDA_CONTACT_ROUTTODIAG
SET CdaRepresentativeRouttodiag = null
