Custom index for SQL Server
Use this index for an SQL Server database.
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_ACCTACT_ACCTSRVKEY'
AND object_id = OBJECT_ID('BILLING.ACCOUNTACTIVITY'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_ACCTACT_ACCTSRVKEY]
ON BILLING.ACCOUNTACTIVITY(ACCOUNTSERVICEKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_ACCTACT_ACCTSRVKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_ACCTACT_ACCTSRVKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_ACCTACT_PENALTY'
AND object_id = OBJECT_ID('BILLING.ACCOUNTACTIVITY'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_ACCTACT_PENALTY]
ON BILLING.ACCOUNTACTIVITY(PENALTYKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_ACCTACT_PENALTY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_ACCTACT_PENALTY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_ACCTTW_ACCTKEY'
AND object_id = OBJECT_ID('BILLING.ACCOUNTTRADEWASTE'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_ACCTTW_ACCTKEY]
ON BILLING.ACCOUNTTRADEWASTE(ACCOUNTKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_ACCTTW_ACCTKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_ACCTTW_ACCTKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_ACCTTW_ACCTSRVKEY'
AND object_id = OBJECT_ID('BILLING.ACCOUNTTRADEWASTE'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_ACCTTW_ACCTSRVKEY]
ON BILLING.ACCOUNTTRADEWASTE(ACCOUNTSERVICEKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_ACCTTW_ACCTSRVKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_ACCTTW_ACCTSRVKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_ACCTWST_ACCTTW '
AND object_id = OBJECT_ID('BILLING.ACCOUNTWASTE'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_ACCTWST_ACCTTW ]
ON BILLING.ACCOUNTWASTE(ACCOUNTTRADEWASTEKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_ACCTWST_ACCTTW '
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_ACCTWST_ACCTTW '
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_ACCTWSTRES_ACCTTW'
AND object_id = OBJECT_ID('BILLING.ACCOUNTWASTERESULT'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_ACCTWSTRES_ACCTTW]
ON BILLING.ACCOUNTWASTERESULT(ACCOUNTTRADEWASTEKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_ACCTWSTRES_ACCTTW'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_ACCTWSTRES_ACCTTW'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_BBPAYEX_ACCTKEY'
AND object_id = OBJECT_ID('BILLING.BBPAYMENTEXCEPTION'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_BBPAYEX_ACCTKEY]
ON BILLING.BBPAYMENTEXCEPTION(ACCOUNTKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_BBPAYEX_ACCTKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_BBPAYEX_ACCTKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_BBSETSCH'
AND object_id = OBJECT_ID('BILLING.SETTLEMENTSCHEDULE'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_BBSETSCH]
ON BILLING.SETTLEMENTSCHEDULE(SETTLEMENTKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_BBSETSCH'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_BBSETSCH'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_BILLMESSAGE_BILLKEY'
AND object_id = OBJECT_ID('BILLING.BILLMESSAGES'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_BILLMESSAGE_BILLKEY]
ON BILLING.BILLMESSAGES(BILLKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_BILLMESSAGE_BILLKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_BILLMESSAGE_BILLKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_BILLRUN_ACCTKEY'
AND object_id = OBJECT_ID('BILLING.BILLRUN'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_BILLRUN_ACCTKEY]
ON BILLING.BILLRUN(ACCOUNTKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_BILLRUN_ACCTKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_BILLRUN_ACCTKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_BPAYALERTEX_ACALKEY'
AND object_id = OBJECT_ID('BILLING.BATCHPAYMENTALERTEXCEPTION'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_BPAYALERTEX_ACALKEY]
ON BILLING.BATCHPAYMENTALERTEXCEPTION(ACALRTKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_BPAYALERTEX_ACALKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_BPAYALERTEX_ACALKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_BTYPEMSGSET_ACCTKEY'
AND object_id = OBJECT_ID('BILLING.BILLTYPEMESSAGESSETUP'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_BTYPEMSGSET_ACCTKEY]
ON BILLING.BILLTYPEMESSAGESSETUP(ACCOUNTKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_BTYPEMSGSET_ACCTKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_BTYPEMSGSET_ACCTKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_DDSCH_LATBILL'
AND object_id = OBJECT_ID('BILLING.DEBITSCHEDULE'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_DDSCH_LATBILL]
ON BILLING.DEBITSCHEDULE(LATESTELIGIBLEBILL)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_DDSCH_LATBILL'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_DDSCH_LATBILL'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_DELINQHIST_BILLKEY'
AND object_id = OBJECT_ID('BILLING.DELINQUENCYHISTORY'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_DELINQHIST_BILLKEY]
ON BILLING.DELINQUENCYHISTORY(BILLKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_DELINQHIST_BILLKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_DELINQHIST_BILLKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_DEPADJ_ACCTKEY'
AND object_id = OBJECT_ID('BILLING.DEPOSITADJUSTMENT'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_DEPADJ_ACCTKEY]
ON BILLING.DEPOSITADJUSTMENT(ACCOUNTKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_DEPADJ_ACCTKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_DEPADJ_ACCTKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_LIIMP_ACCTKEY'
AND object_id = OBJECT_ID('BILLING.LINEITEMIMPERVIOUSAREA'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_LIIMP_ACCTKEY]
ON BILLING.LINEITEMIMPERVIOUSAREA(ACCOUNTKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_LIIMP_ACCTKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_LIIMP_ACCTKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_LIP_ACCTKEY'
AND object_id = OBJECT_ID('BILLING.LINEITEMPENALTY'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_LIP_ACCTKEY]
ON BILLING.LINEITEMPENALTY(ACCOUNTKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_LIP_ACCTKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_LIP_ACCTKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_LITRREADING_LI'
AND object_id = OBJECT_ID('BILLING.LINEITEMTRACKEDREAD'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_LITRREADING_LI]
ON BILLING.LINEITEMTRACKEDREAD(LINEITEMKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_LITRREADING_LI'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_LITRREADING_LI'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_NSFIMPDET_PAYBATCH'
AND object_id = OBJECT_ID('BILLING.NSFIMPORTACTIVITYDETAILS'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_NSFIMPDET_PAYBATCH]
ON BILLING.NSFIMPORTACTIVITYDETAILS(PAYMENTBATCHKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_NSFIMPDET_PAYBATCH'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_NSFIMPDET_PAYBATCH'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_OOCSETUP_OOC'
AND object_id = OBJECT_ID('BILLING.AUTOMATEDONEOFFCHARGESETUP'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_OOCSETUP_OOC]
ON BILLING.AUTOMATEDONEOFFCHARGESETUP(ONEOFFCHARGEKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_OOCSETUP_OOC'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_OOCSETUP_OOC'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_RITEM_REFUND'
AND object_id = OBJECT_ID('BILLING.REFUNDITEM'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_RITEM_REFUND]
ON BILLING.REFUNDITEM(REFUNDKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_RITEM_REFUND'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_RITEM_REFUND'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_SEWTR_ACCTPOSKEY'
AND object_id = OBJECT_ID('BILLING.SEWERTRACKEDREADING'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_SEWTR_ACCTPOSKEY]
ON BILLING.SEWERTRACKEDREADING(ACCTSERVICEPOSITIONKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_SEWTR_ACCTPOSKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_SEWTR_ACCTPOSKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_STTRREAD_ACCTSRVPOS'
AND object_id = OBJECT_ID('BILLING.STORMTRACKREADING'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_STTRREAD_ACCTSRVPOS]
ON BILLING.STORMTRACKREADING(ACCTSERVICEPOSITIONKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_STTRREAD_ACCTSRVPOS'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_STTRREAD_ACCTSRVPOS'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'CASHIERING.IDX_ARC_IC_ACCCTKEY'
AND object_id = OBJECT_ID('CASHIERING.INTERNALCHARGE'))
BEGIN
BEGIN TRY
CREATE INDEX [CASHIERING.IDX_ARC_IC_ACCCTKEY]
ON CASHIERING.INTERNALCHARGE(ACCTKEY)
PRINT 'CREATED INDEX: CASHIERING.IDX_ARC_IC_ACCCTKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: CASHIERING.IDX_ARC_IC_ACCCTKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'CASHIERING.IDX_ARC_IC_ADJ'
AND object_id = OBJECT_ID('CASHIERING.INTERNALCHARGE'))
BEGIN
BEGIN TRY
CREATE INDEX [CASHIERING.IDX_ARC_IC_ADJ]
ON CASHIERING.INTERNALCHARGE(ADJUSTMENTKEY)
PRINT 'CREATED INDEX: CASHIERING.IDX_ARC_IC_ADJ'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: CASHIERING.IDX_ARC_IC_ADJ'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'CASHIERING.IDX_ARC_IC_DEPKEY'
AND object_id = OBJECT_ID('CASHIERING.INTERNALCHARGE'))
BEGIN
BEGIN TRY
CREATE INDEX [CASHIERING.IDX_ARC_IC_DEPKEY]
ON CASHIERING.INTERNALCHARGE(DEPOSITKEY)
PRINT 'CREATED INDEX: CASHIERING.IDX_ARC_IC_DEPKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: CASHIERING.IDX_ARC_IC_DEPKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'CASHIERING.IDX_ARC_IC_OOC'
AND object_id = OBJECT_ID('CASHIERING.INTERNALCHARGE'))
BEGIN
BEGIN TRY
CREATE INDEX [CASHIERING.IDX_ARC_IC_OOC]
ON CASHIERING.INTERNALCHARGE(ONEOFFKEY)
PRINT 'CREATED INDEX: CASHIERING.IDX_ARC_IC_OOC'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: CASHIERING.IDX_ARC_IC_OOC'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'CORE_BATCHPROCESSING.IDX_ARC_USREX_ACCT'
AND object_id = OBJECT_ID('CORE_BATCHPROCESSING.USEREXCEPTION'))
BEGIN
BEGIN TRY
CREATE INDEX [CORE_BATCHPROCESSING.IDX_ARC_USREX_ACCT]
ON CORE_BATCHPROCESSING.USEREXCEPTION(ACCOUNTKEY)
PRINT 'CREATED INDEX: CORE_BATCHPROCESSING.IDX_ARC_USREX_ACCT'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: CORE_BATCHPROCESSING.IDX_ARC_USREX_ACCT'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'CORE_CORRESPONDENCE.IDX_ARC_BOPMETER_BILL'
AND object_id = OBJECT_ID('CORE_CORRESPONDENCE.BILLOUTPUTMETER'))
BEGIN
BEGIN TRY
CREATE INDEX [CORE_CORRESPONDENCE.IDX_ARC_BOPMETER_BILL]
ON CORE_CORRESPONDENCE.BILLOUTPUTMETER(BILLKEY)
PRINT 'CREATED INDEX: CORE_CORRESPONDENCE.IDX_ARC_BOPMETER_BILL'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: CORE_CORRESPONDENCE.IDX_ARC_BOPMETER_BILL'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_ACCT_COMMENTSKEY'
AND object_id = OBJECT_ID('BILLING.ACCOUNT'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_ACCT_COMMENTSKEY]
ON BILLING.ACCOUNT(COMMENTSKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_ACCT_COMMENTSKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_ACCT_COMMENTSKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_ACCTDD_COMMENTSKEY'
AND object_id = OBJECT_ID('BILLING.ACCOUNTDIRECTDEBIT'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_ACCTDD_COMMENTSKEY]
ON BILLING.ACCOUNTDIRECTDEBIT(COMMENTSKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_ACCTDD_COMMENTSKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_ACCTDD_COMMENTSKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_ACCTSVC_COMMENTSKEY'
AND object_id = OBJECT_ID('BILLING.ACCOUNTSERVICE'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_ACCTSVC_COMMENTSKEY]
ON BILLING.ACCOUNTSERVICE(COMMENTSKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_ACCTSVC_COMMENTSKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_ACCTSVC_COMMENTSKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_ACCTTRAN_COMMENTSKEY'
AND object_id = OBJECT_ID('BILLING.ACCTTRAN'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_ACCTTRAN_COMMENTSKEY]
ON BILLING.ACCTTRAN(COMMENTSKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_ACCTTRAN_COMMENTSKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_ACCTTRAN_COMMENTSKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_ACCTTW_COMMENTSKEY'
AND object_id = OBJECT_ID('BILLING.ACCOUNTTRADEWASTE'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_ACCTTW_COMMENTSKEY]
ON BILLING.ACCOUNTTRADEWASTE(COMMENTKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_ACCTTW_COMMENTSKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_ACCTTW_COMMENTSKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_ADJ_COMMENTSKEY'
AND object_id = OBJECT_ID('BILLING.ADJUSTMENT'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_ADJ_COMMENTSKEY]
ON BILLING.ADJUSTMENT(COMMENTSKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_ADJ_COMMENTSKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_ADJ_COMMENTSKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_ADJAPP_COMMENTSKEYA'
AND object_id = OBJECT_ID('BILLING.ADJUSTMENTAPPROVAL'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_ADJAPP_COMMENTSKEYA]
ON BILLING.ADJUSTMENTAPPROVAL(APPROVALCOMMENTS)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_ADJAPP_COMMENTSKEYA'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_ADJAPP_COMMENTSKEYA'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_ADJAPP_COMMENTSKEYR'
AND object_id = OBJECT_ID('BILLING.ADJUSTMENTAPPROVAL'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_ADJAPP_COMMENTSKEYR]
ON BILLING.ADJUSTMENTAPPROVAL(REJECTIONCOMMENTS)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_ADJAPP_COMMENTSKEYR'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_ADJAPP_COMMENTSKEYR'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_ADJAPP_COMMENTSKEYS'
AND object_id = OBJECT_ID('BILLING.ADJUSTMENTAPPROVAL'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_ADJAPP_COMMENTSKEYS]
ON BILLING.ADJUSTMENTAPPROVAL(SUBMISSIONCOMMENTS)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_ADJAPP_COMMENTSKEYS'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_ADJAPP_COMMENTSKEYS'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_BBPLAN_COMMENTSKEY'
AND object_id = OBJECT_ID('BILLING.BUDGETBILLINGPLAN'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_BBPLAN_COMMENTSKEY]
ON BILLING.BUDGETBILLINGPLAN(COMMENTS)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_BBPLAN_COMMENTSKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_BBPLAN_COMMENTSKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_BTIS_COMMENTSKEY'
AND object_id = OBJECT_ID('BILLING.BILLTYPEINSERTSETUP'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_BTIS_COMMENTSKEY]
ON BILLING.BILLTYPEINSERTSETUP(COMMENTSKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_BTIS_COMMENTSKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_BTIS_COMMENTSKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_BTYPE_COMMENTSKEY'
AND object_id = OBJECT_ID('BILLING.BILLTYPE'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_BTYPE_COMMENTSKEY]
ON BILLING.BILLTYPE(COMMENTSKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_BTYPE_COMMENTSKEY'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_BTYPE_COMMENTSKEY'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_DDRUN_COMMENTSKEYS'
AND object_id = OBJECT_ID('BILLING.DIRECTDEBITRUN'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_DDRUN_COMMENTSKEYS]
ON BILLING.DIRECTDEBITRUN(COMMENTSKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_DDRUN_COMMENTSKEYS'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_DDRUN_COMMENTSKEYS'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_DEPADJAPP_COMMENTSKEYA'
AND object_id = OBJECT_ID('BILLING.DEPOSITADJUSTMENTAPPROVAL'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_DEPADJAPP_COMMENTSKEYA]
ON BILLING.DEPOSITADJUSTMENTAPPROVAL(APPROVALCOMMENTS)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_DEPADJAPP_COMMENTSKEYA'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_DEPADJAPP_COMMENTSKEYA'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_DEPADJAPP_COMMENTSKEYR'
AND object_id = OBJECT_ID('BILLING.DEPOSITADJUSTMENTAPPROVAL'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_DEPADJAPP_COMMENTSKEYR]
ON BILLING.DEPOSITADJUSTMENTAPPROVAL(REJECTIONCOMMENTS)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_DEPADJAPP_COMMENTSKEYR'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_DEPADJAPP_COMMENTSKEYR'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_DEPADJAPP_COMMENTSKEYS'
AND object_id = OBJECT_ID('BILLING.DEPOSITADJUSTMENTAPPROVAL'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_DEPADJAPP_COMMENTSKEYS]
ON BILLING.DEPOSITADJUSTMENTAPPROVAL(SUBMISSIONCOMMENTS)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_DEPADJAPP_COMMENTSKEYS'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_DEPADJAPP_COMMENTSKEYS'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_DEPCHG_COMMENTSKEYS'
AND object_id = OBJECT_ID('BILLING.DEPOSITCHARGE'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_DEPCHG_COMMENTSKEYS]
ON BILLING.DEPOSITCHARGE(COMMENTSKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_DEPCHG_COMMENTSKEYS'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_DEPCHG_COMMENTSKEYS'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_DEPTRAN_COMMENTSKEYS'
AND object_id = OBJECT_ID('BILLING.DEPTRAN'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_DEPTRAN_COMMENTSKEYS]
ON BILLING.DEPTRAN(COMMENTSKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_DEPTRAN_COMMENTSKEYS'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_DEPTRAN_COMMENTSKEYS'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_LI_COMMENTSKEYS'
AND object_id = OBJECT_ID('BILLING.LINEITEM'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_LI_COMMENTSKEYS]
ON BILLING.LINEITEM(COMMENTSKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_LI_COMMENTSKEYS'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_LI_COMMENTSKEYS'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_LISP_COMMENTSKEYS'
AND object_id = OBJECT_ID('BILLING.LINEITEMSETUP'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_LISP_COMMENTSKEYS]
ON BILLING.LINEITEMSETUP(COMMENTSKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_LISP_COMMENTSKEYS'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_LISP_COMMENTSKEYS'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_OOC_COMMENTSKEYS'
AND object_id = OBJECT_ID('BILLING.ONEOFFCHARGE'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_OOC_COMMENTSKEYS]
ON BILLING.ONEOFFCHARGE(COMMENTSKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_OOC_COMMENTSKEYS'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_OOC_COMMENTSKEYS'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_PAYBATCH_COMMENTSKEYS'
AND object_id = OBJECT_ID('BILLING.PAYBATCH'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_PAYBATCH_COMMENTSKEYS]
ON BILLING.PAYBATCH(COMMENTSKEY)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_PAYBATCH_COMMENTSKEYS'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_PAYBATCH_COMMENTSKEYS'
END CATCH
END
IF NOT EXISTS(SELECT * FROM sys.indexes
WHERE name = 'BILLING.IDX_ARC_REFUNDSUB_COMMENTSKEYS'
AND object_id = OBJECT_ID('BILLING.REFUNDAPPROVAL'))
BEGIN
BEGIN TRY
CREATE INDEX [BILLING.IDX_ARC_REFUNDSUB_COMMENTSKEYS]
ON BILLING.REFUNDAPPROVAL(SUBMISSIONCOMMENTS)
PRINT 'CREATED INDEX: BILLING.IDX_ARC_REFUNDSUB_COMMENTSKEYS'
END TRY
BEGIN CATCH
PRINT 'SKIPPING INDEX: BILLING.IDX_ARC_REFUNDSUB_COMMENTSKEYS'
END CATCH
END