------------------------------------------------------------------
--                                                              --
--  File:   Create_TR_Indexes                                   --
--          Copyright Microsoft  2010, 2011, 2012               --
--                                                              --
------------------------------------------------------------------
USE tpce
GO
 
---
--- Set connection attributes
---
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
SET ARITHABORT ON
SET CONCAT_NULL_YIELDS_NULL ON
SET QUOTED_IDENTIFIER ON
SET NUMERIC_ROUNDABORT OFF
GO

IF EXISTS ( SELECT name FROM sysindexes WHERE name = 'IX_TRADE_REQUEST_NC1' )
    DROP INDEX IX_TRADE_REQUEST_NC1 ON TRADE_REQUEST
GO

IF EXISTS ( SELECT name FROM sysindexes WHERE name = 'IX_TRADE_REQUEST_NC3' )
    DROP INDEX IX_TRADE_REQUEST_NC3 ON TRADE_REQUEST
GO

IF NOT EXISTS ( SELECT name FROM sysindexes WHERE name = 'IX_TRADE_REQUEST_NC1' )
    CREATE UNIQUE NONCLUSTERED INDEX IX_TRADE_REQUEST_NC1 ON TRADE_REQUEST(TR_B_ID ASC, TR_S_SYMB ASC, TR_T_ID ASC)
        INCLUDE (TR_BID_PRICE, TR_QTY)
        WITH (ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100, MAXDOP = 2)
        ON tpce_fg
GO

CHECKPOINT
GO

