
IF NOT EXISTS (SELECT * FROM sys.columns WHERE object_id = OBJECT_ID(N'[AKUZ].[T_CDA_SECTION_BENEFITS_V4]') AND name = N'CdaAmbulatorySummaryDocumentV4_UQ')
ALTER TABLE [AKUZ].[T_CDA_SECTION_BENEFITS_V4]ADD [CdaAmbulatorySummaryDocumentV4_UQ] AS (CASE WHEN [CdaAmbulatorySummaryDocumentV4] IS NOT NULL THEN NULL ELSE [CdaSectionBenefitsV4ID] END)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[AKUZ].[T_CDA_SECTION_BENEFITS_V4]') AND name = N'UQ_T_CDA_SECTION_BENEFITS_V4_CdaAmbulatorySummaryDocumentV4' and is_unique_constraint <> 1)
CREATE UNIQUE NONCLUSTERED INDEX [UQ_T_CDA_SECTION_BENEFITS_V4_CdaAmbulatorySummaryDocumentV4] ON [AKUZ].[T_CDA_SECTION_BENEFITS_V4] ([CdaAmbulatorySummaryDocumentV4] ASC, [CdaAmbulatorySummaryDocumentV4_UQ] ASC) ON [PRIMARY]
GO

