--ama201

-- NCIX_entry_covering_acounting  
IF INDEXPROPERTY(OBJECT_ID('dbo.Entry'), 'NCIX_entry_covering_acounting', 'IndexID') IS NOT NULL
BEGIN;
	PRINT 'idx NCIX_entry_covering_acounting drop'
    DROP INDEX dbo.Entry.NCIX_entry_covering_acounting;
END;

-- NCIX_entry_ET_reconciliation_status  
IF INDEXPROPERTY(OBJECT_ID('dbo.Entry'), 'NCIX_entry_ET_reconciliation_status', 'IndexID') IS NOT NULL
BEGIN;
    PRINT 'idx NCIX_entry_ET_reconciliation_status drop';
    DROP INDEX dbo.Entry.NCIX_entry_ET_reconciliation_status;
END;
GO

IF INDEXPROPERTY(OBJECT_ID('dbo.Entry'), 'NCIX_entry_COL_ET_reconciliation_status', 'IndexID') IS NOT NULL
BEGIN;
    PRINT 'idx NCIX_entry_COL_ET_reconciliation_status drop';
    DROP INDEX dbo.Entry.NCIX_entry_COL_ET_reconciliation_status;
END;
GO
IF INDEXPROPERTY(OBJECT_ID('dbo.Entry'), 'NCIX_entry_COL_ET_reconciliation_status', 'IndexID') IS NULL
BEGIN;
    PRINT 'idx NCIX_entry_COL_ET_reconciliation_status create';
    CREATE NONCLUSTERED INDEX NCIX_entry_COL_ET_reconciliation_status
    ON [dbo].[Entry] ([ET_reconciliation_status])
    INCLUDE
    ([ET_document_header],
     [ET_account],
     [ET_debit_base_amount],
     [ET_credit_base_amount],
     [ET_reconciliation_base_amount]
    );
END;
GO

-- NCIX_Document_header_COL_DH_predefined_entry  
IF INDEXPROPERTY(OBJECT_ID('dbo.Document_header'), 'NCIX_Document_header_COL_DH_predefined_entry' , 'IndexID' ) IS NOT NULL 
BEGIN;   
	PRINT 'idx NCIX_Document_header_COL_DH_predefined_entry drop'
	DROP INDEX dbo.Document_header.NCIX_Document_header_COL_DH_predefined_entry;  
END;  
GO  

IF INDEXPROPERTY(OBJECT_ID('dbo.Document_header'), 'NCIX_Document_header_COL_DH_predefined_entry' , 'IndexID' ) IS NULL
BEGIN;   
	PRINT 'idx NCIX_Document_header_COL_DH_predefined_entry create'
	CREATE INDEX NCIX_Document_header_COL_DH_predefined_entry ON dbo.Document_header(DH_predefined_entry, DH_state) INCLUDE(Document_header_ID, DH_doc_date);  
END;  
GO  


