----------------------------------------------------------------
--                                                              
--  File:   Create_TID_Range_Table.SQL                          
--          Microsoft TPC-E Benchmark Kit Ver. 1.14.0-1031      
--          Copyright Microsoft, 2008-2015                  
--                                                              
----------------------------------------------------------------
USE tpce
GO

---
--- Set connection attributes
---
SET ANSI_NULLS ON
SET ANSI_NULL_DFLT_OFF OFF
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 sysobjects WHERE name = 'TID_RANGES' )
    DROP TABLE TID_RANGES
GO


CREATE TABLE TID_RANGES (
                            SPID        smallint      PRIMARY KEY,
                            NEXT_T_ID   bigint,
                            MAX_T_ID    bigint
                        )
ON fixed_fg
GO

INSERT  INTO TID_RANGES         -- initialize the TID Range table
SELECT  -1,                     -- define a range large enough for the longest possible run
        MAX(T_ID) + 1,          -- the select statement gets the maximum initial/run time T_ID value
        100000
FROM    TRADE
GO

--- verify the table population
SELECT  *
FROM    TID_RANGES
GO
