IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[EMDR].[T_SDW_LOGGING]') AND name = N'NonClusteredIndex-20230831-160455')
DROP INDEX [NonClusteredIndex-20230831-160455] ON [EMDR].[T_SDW_LOGGING]
GO
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[EMDR].[T_SIGN]') AND name = N'IX_T_SIGN_Signer')
DROP INDEX [IX_T_SIGN_Signer] ON [EMDR].[T_SIGN]
GO
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[EMDR].[T_SIGN]') AND name = N'IX_T_SIGN_CheckSum')
DROP INDEX [IX_T_SIGN_CheckSum] ON [EMDR].[T_SIGN]
GO
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[VCLib].[T_FILE_CONTENT]') AND name = N'IX_T_FILE_CONTENT_Length')
DROP INDEX [IX_T_FILE_CONTENT_Length] ON [VCLib].[T_FILE_CONTENT] 
GO
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[EMDR].[T_IEMK_PACKAGE]') AND name = N'IX_IEMK_PACKAGE_EmdrMessage')
DROP INDEX [IX_IEMK_PACKAGE_EmdrMessage] ON [EMDR].[T_IEMK_PACKAGE]
GO
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[EMDR].[T_PATIENT]') AND name = N'IX_T_PATIENT_ENP')
DROP INDEX [IX_T_PATIENT_ENP] ON [EMDR].[T_PATIENT]
GO
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[EMDR].[T_EMPR_ASSOCIATION]') AND name = N'IX_T_EMPR_ASSOCIATION_MessageId')
DROP INDEX [IX_T_EMPR_ASSOCIATION_MessageId] ON [EMDR].[T_EMPR_ASSOCIATION]
GO
IF  NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[EMDR].[T_EMPR_ASSOCIATION]') AND name = N'ix_EMPR_ASSOCIATION_Target')
CREATE INDEX [ix_EMPR_ASSOCIATION_Target] ON [EMDR].[T_EMPR_ASSOCIATION] ([Target])  WITH (FILLFACTOR=90)
GO
IF  NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[EMDR].[T_EMPR_DETAILS]') AND name = N'EmprParsed')
CREATE INDEX [EmprParsed] ON [EMDR].[T_EMPR_DETAILS] ([EmprParsed])  WITH (FILLFACTOR=90, SORT_IN_TEMPDB = ON)
GO