text: ﻿/*
  Deployment script for HorseRacing
  
  This code was generated by a tool.
  Changes to this file may cause incorrect behavior and will be lost if
  the code is regenerated.
  */
  
  GO
  SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;
  
  SET NUMERIC_ROUNDABORT OFF;
  
  
  GO
  :setvar DatabaseName "HorseRacing"
  :setvar DefaultFilePrefix "HorseRacing"
  :setvar DefaultDataPath "C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\"
  :setvar DefaultLogPath "C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\"
  
  GO
  :on error exit
  GO
  /*
  Detect SQLCMD mode and disable script execution if SQLCMD mode is not supported.
  To re-enable the script after enabling SQLCMD mode, execute the following:
  SET NOEXEC OFF; 
  */
  :setvar __IsSqlCmdEnabled "True"
  GO
  IF N'$(__IsSqlCmdEnabled)' NOT LIKE N'True'
      BEGIN
          PRINT N'SQLCMD mode must be enabled to successfully execute this script.';
          SET NOEXEC ON;
      END
  
  
  GO
  USE [master];
  
  
  GO
  
  IF (DB_ID(N'$(DatabaseName)') IS NOT NULL) 
  BEGIN
      ALTER DATABASE [$(DatabaseName)]
      SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
      DROP DATABASE [$(DatabaseName)];
  END
  
  GO
  PRINT N'Creating $(DatabaseName)...'
  GO
  CREATE DATABASE [$(DatabaseName)]
      ON 
      PRIMARY(NAME = [$(DatabaseName)], FILENAME = N'$(DefaultDataPath)$(DefaultFilePrefix)_Primary.mdf')
      LOG ON (NAME = [$(DatabaseName)_log], FILENAME = N'$(DefaultLogPath)$(DefaultFilePrefix)_Primary.ldf') COLLATE Latin1_General_CI_AS
  GO
  IF EXISTS (SELECT 1
             FROM   [master].[dbo].[sysdatabases]
             WHERE  [name] = N'$(DatabaseName)')
      BEGIN
          ALTER DATABASE [$(DatabaseName)]
              SET AUTO_CLOSE OFF 
              WITH ROLLBACK IMMEDIATE;
      END
  
  
  GO
  USE [$(DatabaseName)];
  
  
  GO
  IF EXISTS (SELECT 1
             FROM   [master].[dbo].[sysdatabases]
             WHERE  [name] = N'$(DatabaseName)')
      BEGIN
          ALTER DATABASE [$(DatabaseName)]
              SET ANSI_NULLS ON,
                  ANSI_PADDING ON,
                  ANSI_WARNINGS ON,
                  ARITHABORT ON,
                  CONCAT_NULL_YIELDS_NULL ON,
                  NUMERIC_ROUNDABORT OFF,
                  QUOTED_IDENTIFIER ON,
                  ANSI_NULL_DEFAULT ON,
                  CURSOR_DEFAULT LOCAL,
                  RECOVERY FULL,
                  CURSOR_CLOSE_ON_COMMIT OFF,
                  AUTO_CREATE_STATISTICS ON,
                  AUTO_SHRINK OFF,
                  AUTO_UPDATE_STATISTICS ON,
                  RECURSIVE_TRIGGERS OFF 
              WITH ROLLBACK IMMEDIATE;
      END
  
  
  GO
  IF EXISTS (SELECT 1
             FROM   [master].[dbo].[sysdatabases]
             WHERE  [name] = N'$(DatabaseName)')
      BEGIN
          ALTER DATABASE [$(DatabaseName)]
              SET ALLOW_SNAPSHOT_ISOLATION OFF;
      END
  
  
  GO
  IF EXISTS (SELECT 1
             FROM   [master].[dbo].[sysdatabases]
             WHERE  [name] = N'$(DatabaseName)')
      BEGIN
          ALTER DATABASE [$(DatabaseName)]
              SET READ_COMMITTED_SNAPSHOT OFF 
              WITH ROLLBACK IMMEDIATE;
      END
  
  
  GO
  IF EXISTS (SELECT 1
             FROM   [master].[dbo].[sysdatabases]
             WHERE  [name] = N'$(DatabaseName)')
      BEGIN
          ALTER DATABASE [$(DatabaseName)]
              SET AUTO_UPDATE_STATISTICS_ASYNC OFF,
                  PAGE_VERIFY NONE,
                  DATE_CORRELATION_OPTIMIZATION OFF,
                  DISABLE_BROKER,
                  PARAMETERIZATION SIMPLE,
                  SUPPLEMENTAL_LOGGING OFF 
              WITH ROLLBACK IMMEDIATE;
      END
  
  
  GO
  IF IS_SRVROLEMEMBER(N'sysadmin') = 1
      BEGIN
          IF EXISTS (SELECT 1
                     FROM   [master].[dbo].[sysdatabases]
                     WHERE  [name] = N'$(DatabaseName)')
              BEGIN
                  EXECUTE sp_executesql N'ALTER DATABASE [$(DatabaseName)]
      SET TRUSTWORTHY OFF,
          DB_CHAINING OFF 
      WITH ROLLBACK IMMEDIATE';
              END
      END
  ELSE
      BEGIN
          PRINT N'The database settings cannot be modified. You must be a SysAdmin to apply these settings.';
      END
  
  
  GO
  IF IS_SRVROLEMEMBER(N'sysadmin') = 1
      BEGIN
          IF EXISTS (SELECT 1
                     FROM   [master].[dbo].[sysdatabases]
                     WHERE  [name] = N'$(DatabaseName)')
              BEGIN
                  EXECUTE sp_executesql N'ALTER DATABASE [$(DatabaseName)]
      SET HONOR_BROKER_PRIORITY OFF 
      WITH ROLLBACK IMMEDIATE';
              END
      END
  ELSE
      BEGIN
          PRINT N'The database settings cannot be modified. You must be a SysAdmin to apply these settings.';
      END
  
  
  GO
  ALTER DATABASE [$(DatabaseName)]
      SET TARGET_RECOVERY_TIME = 0 SECONDS 
      WITH ROLLBACK IMMEDIATE;
  
  
  GO
  IF EXISTS (SELECT 1
             FROM   [master].[dbo].[sysdatabases]
             WHERE  [name] = N'$(DatabaseName)')
      BEGIN
          ALTER DATABASE [$(DatabaseName)]
              SET FILESTREAM(NON_TRANSACTED_ACCESS = OFF),
                  CONTAINMENT = NONE 
              WITH ROLLBACK IMMEDIATE;
      END
  
  
  GO
  IF EXISTS (SELECT 1
             FROM   [master].[dbo].[sysdatabases]
             WHERE  [name] = N'$(DatabaseName)')
      BEGIN
          ALTER DATABASE [$(DatabaseName)]
              SET AUTO_CREATE_STATISTICS ON(INCREMENTAL = OFF),
                  MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT = OFF,
                  DELAYED_DURABILITY = DISABLED 
              WITH ROLLBACK IMMEDIATE;
      END
  
  
  GO
  IF EXISTS (SELECT 1
             FROM   [master].[dbo].[sysdatabases]
             WHERE  [name] = N'$(DatabaseName)')
      BEGIN
          ALTER DATABASE [$(DatabaseName)]
              SET QUERY_STORE (QUERY_CAPTURE_MODE = ALL, DATA_FLUSH_INTERVAL_SECONDS = 900, INTERVAL_LENGTH_MINUTES = 60, MAX_PLANS_PER_QUERY = 200, CLEANUP_POLICY = (STALE_QUERY_THRESHOLD_DAYS = 367), MAX_STORAGE_SIZE_MB = 100) 
              WITH ROLLBACK IMMEDIATE;
      END
  
  
  GO
  IF EXISTS (SELECT 1
             FROM   [master].[dbo].[sysdatabases]
             WHERE  [name] = N'$(DatabaseName)')
      BEGIN
          ALTER DATABASE [$(DatabaseName)]
              SET QUERY_STORE = OFF 
              WITH ROLLBACK IMMEDIATE;
      END
  
  
  GO
  IF EXISTS (SELECT 1
             FROM   [master].[dbo].[sysdatabases]
             WHERE  [name] = N'$(DatabaseName)')
      BEGIN
          ALTER DATABASE SCOPED CONFIGURATION SET MAXDOP = 0;
          ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET MAXDOP = PRIMARY;
          ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMATION = OFF;
          ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET LEGACY_CARDINALITY_ESTIMATION = PRIMARY;
          ALTER DATABASE SCOPED CONFIGURATION SET PARAMETER_SNIFFING = ON;
          ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET PARAMETER_SNIFFING = PRIMARY;
          ALTER DATABASE SCOPED CONFIGURATION SET QUERY_OPTIMIZER_HOTFIXES = OFF;
          ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET QUERY_OPTIMIZER_HOTFIXES = PRIMARY;
      END
  
  
  GO
  IF EXISTS (SELECT 1
             FROM   [master].[dbo].[sysdatabases]
             WHERE  [name] = N'$(DatabaseName)')
      BEGIN
          ALTER DATABASE [$(DatabaseName)]
              SET TEMPORAL_HISTORY_RETENTION ON 
              WITH ROLLBACK IMMEDIATE;
      END
  
  
  GO
  IF fulltextserviceproperty(N'IsFulltextInstalled') = 1
      EXECUTE sp_fulltext_database 'enable';
  
  
  GO
  PRINT N'Creating [dbo].[bid]...';
  
  
  GO
  CREATE TABLE [dbo].[bid] (
      [ID]   BIGINT        IDENTITY (1, 1) NOT NULL,
      [Name] VARCHAR (200) NOT NULL,
      CONSTRAINT [PK_bid_ID] PRIMARY KEY CLUSTERED ([ID] ASC),
      CONSTRAINT [ix_bid_Name] UNIQUE NONCLUSTERED ([Name] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[country]...';
  
  
  GO
  CREATE TABLE [dbo].[country] (
      [ID]   BIGINT        IDENTITY (1, 1) NOT NULL,
      [Name] VARCHAR (200) NOT NULL,
      CONSTRAINT [PK_country_ID] PRIMARY KEY CLUSTERED ([ID] ASC),
      CONSTRAINT [ix_country_Name] UNIQUE NONCLUSTERED ([Name] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[course]...';
  
  
  GO
  CREATE TABLE [dbo].[course] (
      [ID]            BIGINT        IDENTITY (1, 1) NOT NULL,
      [Name]          VARCHAR (200) NOT NULL,
      [BFEquivalence] VARCHAR (200) NULL,
      CONSTRAINT [PK_course_ID] PRIMARY KEY CLUSTERED ([ID] ASC),
      CONSTRAINT [ix_course_Name] UNIQUE NONCLUSTERED ([Name] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[distance]...';
  
  
  GO
  CREATE TABLE [dbo].[distance] (
      [ID]       BIGINT        IDENTITY (1, 1) NOT NULL,
      [Name]     VARCHAR (200) NOT NULL,
      [Meters]   REAL          NULL,
      [Furlongs] REAL          NULL,
      CONSTRAINT [PK_distance_ID] PRIMARY KEY CLUSTERED ([ID] ASC),
      CONSTRAINT [ix_distance_Name] UNIQUE NONCLUSTERED ([Name] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[going]...';
  
  
  GO
  CREATE TABLE [dbo].[going] (
      [ID]   BIGINT        IDENTITY (1, 1) NOT NULL,
      [Name] VARCHAR (200) NOT NULL,
      CONSTRAINT [PK_going_ID] PRIMARY KEY CLUSTERED ([ID] ASC),
      CONSTRAINT [ix_going_Name] UNIQUE NONCLUSTERED ([Name] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[headgear]...';
  
  
  GO
  CREATE TABLE [dbo].[headgear] (
      [ID]   BIGINT        IDENTITY (1, 1) NOT NULL,
      [Name] VARCHAR (200) NOT NULL,
      CONSTRAINT [PK_headgear_ID] PRIMARY KEY CLUSTERED ([ID] ASC),
      CONSTRAINT [ix_headgear_Name] UNIQUE NONCLUSTERED ([Name] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[horse]...';
  
  
  GO
  CREATE TABLE [dbo].[horse] (
      [ID]          BIGINT        IDENTITY (1, 1) NOT NULL,
      [Name]        VARCHAR (200) NOT NULL,
      [SelectionID] BIGINT        NULL,
      CONSTRAINT [PK_horse_ID] PRIMARY KEY CLUSTERED ([ID] ASC),
      CONSTRAINT [ix_Horse_Name] UNIQUE NONCLUSTERED ([Name] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[jockey]...';
  
  
  GO
  CREATE TABLE [dbo].[jockey] (
      [ID]   BIGINT        IDENTITY (1, 1) NOT NULL,
      [Name] VARCHAR (200) NOT NULL,
      CONSTRAINT [PK_jockey_ID] PRIMARY KEY CLUSTERED ([ID] ASC),
      CONSTRAINT [ix_Jockey_Name] UNIQUE NONCLUSTERED ([Name] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[OtherPlace]...';
  
  
  GO
  CREATE TABLE [dbo].[OtherPlace] (
      [ID]           BIGINT        IDENTITY (1, 1) NOT NULL,
      [RaceDate]     DATETIME2 (0) NOT NULL,
      [horseID]      BIGINT        NOT NULL,
      [OPPrice05Min] REAL          NOT NULL,
      [OPPrice04Min] REAL          NOT NULL,
      [OPPrice03Min] REAL          NOT NULL,
      [OPPrice02Min] REAL          NOT NULL,
      [OPPrice01Min] REAL          NOT NULL,
      [OPBFSP]       REAL          NOT NULL,
      [OPlaces]      INT           NOT NULL,
      [OPResult]     INT           NOT NULL,
      [OPMarketId]   VARCHAR (50)  NOT NULL,
      [OPEventId]    BIGINT        NOT NULL,
      [OPRaceCardId] BIGINT        NOT NULL,
      CONSTRAINT [PK_OtherPlace_ID] PRIMARY KEY CLUSTERED ([ID] ASC),
      CONSTRAINT [ix_OtherPlace] UNIQUE NONCLUSTERED ([RaceDate] ASC, [horseID] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[outcome]...';
  
  
  GO
  CREATE TABLE [dbo].[outcome] (
      [ID]   BIGINT        IDENTITY (1, 1) NOT NULL,
      [Name] VARCHAR (200) NOT NULL,
      CONSTRAINT [PK_outcome_ID] PRIMARY KEY CLUSTERED ([ID] ASC),
      CONSTRAINT [ix_outcome_Name] UNIQUE NONCLUSTERED ([Name] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[PlacePrice]...';
  
  
  GO
  CREATE TABLE [dbo].[PlacePrice] (
      [ID]          BIGINT        IDENTITY (1, 1) NOT NULL,
      [RaceDate]    DATETIME2 (0) NOT NULL,
      [horseID]     BIGINT        NOT NULL,
      [PPrice05Min] REAL          NOT NULL,
      [PPrice04Min] REAL          NOT NULL,
      [PPrice03Min] REAL          NOT NULL,
      [PPrice02Min] REAL          NOT NULL,
      [PPrice01Min] REAL          NOT NULL,
      [PBFSP]       REAL          NOT NULL,
      [Places]      INT           NOT NULL,
      [PResult]     INT           NOT NULL,
      [PMarketId]   VARCHAR (50)  NOT NULL,
      [PEventId]    BIGINT        NOT NULL,
      [PRaceCardId] BIGINT        NOT NULL,
      CONSTRAINT [PK_PlacePrice_ID] PRIMARY KEY CLUSTERED ([ID] ASC),
      CONSTRAINT [ix_PlacePrice] UNIQUE NONCLUSTERED ([RaceDate] ASC, [horseID] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[RaceCard]...';
  
  
  GO
  CREATE TABLE [dbo].[RaceCard] (
      [ID]           BIGINT        IDENTITY (1, 1) NOT NULL,
      [RaceDate]     DATETIME2 (0) NOT NULL,
      [countryID]    BIGINT        NOT NULL,
      [courseID]     BIGINT        NOT NULL,
      [goingID]      BIGINT        NOT NULL,
      [distanceID]   BIGINT        NOT NULL,
      [racetypeID]   BIGINT        NOT NULL,
      [horseID]      BIGINT        NOT NULL,
      [jockeyID]     BIGINT        NOT NULL,
      [trainerID]    BIGINT        NOT NULL,
      [headGearID]   BIGINT        NULL,
      [Price09am]    REAL          NULL,
      [Price10am]    REAL          NULL,
      [Price11am]    REAL          NULL,
      [Price60Min]   REAL          NULL,
      [Price30Min]   REAL          NULL,
      [Price15Min]   REAL          NULL,
      [Price05Min]   REAL          NULL,
      [Price04Min]   REAL          NULL,
      [Price03Min]   REAL          NULL,
      [Price02Min]   REAL          NULL,
      [Price01Min]   REAL          NULL,
      [BFSP]         REAL          NULL,
      [runners]      INT           NOT NULL,
      [active]       INT           NOT NULL,
      [activeStatus] INT           NOT NULL,
      [sortPriority] INT           NOT NULL,
      [PreMin]       REAL          NOT NULL,
      [PreMax]       REAL          NOT NULL,
      [IPMin]        REAL          NOT NULL,
      [IPMax]        REAL          NOT NULL,
      [PPvol]        FLOAT (50)    NOT NULL,
      [IPvol]        FLOAT (50)    NOT NULL,
      [MarketId]     VARCHAR (50)  NOT NULL,
      [EventId]      BIGINT        NOT NULL,
      CONSTRAINT [PK_RaceCard_ID] PRIMARY KEY CLUSTERED ([ID] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[racetype]...';
  
  
  GO
  CREATE TABLE [dbo].[racetype] (
      [ID]            BIGINT        IDENTITY (1, 1) NOT NULL,
      [Name]          VARCHAR (200) NOT NULL,
      [BFEquivelance] VARCHAR (200) NULL,
      CONSTRAINT [PK_racetype_ID] PRIMARY KEY CLUSTERED ([ID] ASC),
      CONSTRAINT [ix_racetype_Name] UNIQUE NONCLUSTERED ([Name] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[Records]...';
  
  
  GO
  CREATE TABLE [dbo].[Records] (
      [ID]          BIGINT        IDENTITY (1, 1) NOT NULL,
      [systemID]    BIGINT        NOT NULL,
      [RaceDate]    DATETIME2 (0) NOT NULL,
      [marketOpen]  DATETIME2 (3) NOT NULL,
      [selectionID] BIGINT        NOT NULL,
      [bidPlaced]   DATETIME2 (3) NOT NULL,
      [BetId]       BIGINT        NOT NULL,
      [bidID]       BIGINT        NOT NULL,
      [stake]       REAL          NOT NULL,
      [price]       REAL          NOT NULL,
      [outcomeID]   BIGINT        NOT NULL,
      [pnl]         REAL          NOT NULL,
      [netpnl]      REAL          NOT NULL,
      [EventId]     BIGINT        NOT NULL,
      [MarketId]    BIGINT        NOT NULL,
      [RRaceCardId] BIGINT        NOT NULL,
      CONSTRAINT [PK_Records_ID] PRIMARY KEY CLUSTERED ([ID] ASC),
      CONSTRAINT [ix_Records] UNIQUE NONCLUSTERED ([systemID] ASC, [MarketId] ASC, [selectionID] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[system]...';
  
  
  GO
  CREATE TABLE [dbo].[system] (
      [ID]   BIGINT        IDENTITY (1, 1) NOT NULL,
      [Name] VARCHAR (200) NOT NULL,
      CONSTRAINT [PK_system_ID] PRIMARY KEY CLUSTERED ([ID] ASC),
      CONSTRAINT [ix_system_Name] UNIQUE NONCLUSTERED ([Name] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[tick_equivalence]...';
  
  
  GO
  CREATE TABLE [dbo].[tick_equivalence] (
      [ID]      BIGINT IDENTITY (1, 1) NOT NULL,
      [Price]   REAL   NOT NULL,
      [Tick]    INT    NOT NULL,
      [Percent] REAL   NOT NULL,
      CONSTRAINT [PK_tick_equivalence_ID] PRIMARY KEY CLUSTERED ([ID] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[trainer]...';
  
  
  GO
  CREATE TABLE [dbo].[trainer] (
      [ID]   BIGINT        IDENTITY (1, 1) NOT NULL,
      [Name] VARCHAR (200) NOT NULL,
      CONSTRAINT [ix_trainer_Name] UNIQUE NONCLUSTERED ([Name] ASC),
      CONSTRAINT [PK_trainer_ID] UNIQUE NONCLUSTERED ([ID] ASC)
  );
  
  
  GO
  PRINT N'Creating [dbo].[DF__distance__Meters__25869641]...';
  
  
  GO
  ALTER TABLE [dbo].[distance]
      ADD CONSTRAINT [DF__distance__Meters__25869641] DEFAULT (NULL) FOR [Meters];
  
  
  GO
  PRINT N'Creating [dbo].[DF__distance__Furlon__267ABA7A]...';
  
  
  GO
  ALTER TABLE [dbo].[distance]
      ADD CONSTRAINT [DF__distance__Furlon__267ABA7A] DEFAULT (NULL) FOR [Furlongs];
  
  
  GO
  PRINT N'Creating [dbo].[FK_OtherPlace_Racecard]...';
  
  
  GO
  ALTER TABLE [dbo].[OtherPlace]
      ADD CONSTRAINT [FK_OtherPlace_Racecard] FOREIGN KEY ([OPRaceCardId]) REFERENCES [dbo].[RaceCard] ([ID]);
  
  
  GO
  PRINT N'Creating [dbo].[FK_PlacePrice_RaceCard]...';
  
  
  GO
  ALTER TABLE [dbo].[PlacePrice]
      ADD CONSTRAINT [FK_PlacePrice_RaceCard] FOREIGN KEY ([PRaceCardId]) REFERENCES [dbo].[RaceCard] ([ID]);
  
  
  GO
  PRINT N'Creating [dbo].[FK_RaceCard_country]...';
  
  
  GO
  ALTER TABLE [dbo].[RaceCard]
      ADD CONSTRAINT [FK_RaceCard_country] FOREIGN KEY ([countryID]) REFERENCES [dbo].[country] ([ID]);
  
  
  GO
  PRINT N'Creating [dbo].[FK_RaceCard_course]...';
  
  
  GO
  ALTER TABLE [dbo].[RaceCard]
      ADD CONSTRAINT [FK_RaceCard_course] FOREIGN KEY ([courseID]) REFERENCES [dbo].[course] ([ID]);
  
  
  GO
  PRINT N'Creating [dbo].[FK_RaceCard_distance]...';
  
  
  GO
  ALTER TABLE [dbo].[RaceCard]
      ADD CONSTRAINT [FK_RaceCard_distance] FOREIGN KEY ([distanceID]) REFERENCES [dbo].[distance] ([ID]);
  
  
  GO
  PRINT N'Creating [dbo].[FK_RaceCard_going]...';
  
  
  GO
  ALTER TABLE [dbo].[RaceCard]
      ADD CONSTRAINT [FK_RaceCard_going] FOREIGN KEY ([goingID]) REFERENCES [dbo].[going] ([ID]);
  
  
  GO
  PRINT N'Creating [dbo].[FK_RaceCard_headgear]...';
  
  
  GO
  ALTER TABLE [dbo].[RaceCard]
      ADD CONSTRAINT [FK_RaceCard_headgear] FOREIGN KEY ([headGearID]) REFERENCES [dbo].[headgear] ([ID]);
  
  
  GO
  PRINT N'Creating [dbo].[FK_RaceCard_horse]...';
  
  
  GO
  ALTER TABLE [dbo].[RaceCard]
      ADD CONSTRAINT [FK_RaceCard_horse] FOREIGN KEY ([horseID]) REFERENCES [dbo].[horse] ([ID]);
  
  
  GO
  PRINT N'Creating [dbo].[FK_RaceCard_jockey]...';
  
  
  GO
  ALTER TABLE [dbo].[RaceCard]
      ADD CONSTRAINT [FK_RaceCard_jockey] FOREIGN KEY ([jockeyID]) REFERENCES [dbo].[jockey] ([ID]);
  
  
  GO
  PRINT N'Creating [dbo].[FK_RaceCard_trainer]...';
  
  
  GO
  ALTER TABLE [dbo].[RaceCard]
      ADD CONSTRAINT [FK_RaceCard_trainer] FOREIGN KEY ([trainerID]) REFERENCES [dbo].[trainer] ([ID]);
  
  
  GO
  PRINT N'Creating [dbo].[FK_RaceCard_racetype]...';
  
  
  GO
  ALTER TABLE [dbo].[RaceCard]
      ADD CONSTRAINT [FK_RaceCard_racetype] FOREIGN KEY ([racetypeID]) REFERENCES [dbo].[racetype] ([ID]);
  
  
  GO
  PRINT N'Creating [dbo].[FK_Records_bid]...';
  
  
  GO
  ALTER TABLE [dbo].[Records]
      ADD CONSTRAINT [FK_Records_bid] FOREIGN KEY ([bidID]) REFERENCES [dbo].[bid] ([ID]);
  
  
  GO
  PRINT N'Creating [dbo].[FK_Records_outcome]...';
  
  
  GO
  ALTER TABLE [dbo].[Records]
      ADD CONSTRAINT [FK_Records_outcome] FOREIGN KEY ([outcomeID]) REFERENCES [dbo].[outcome] ([ID]);
  
  
  GO
  PRINT N'Creating [dbo].[FK_Records_Racecard]...';
  
  
  GO
  ALTER TABLE [dbo].[Records]
      ADD CONSTRAINT [FK_Records_Racecard] FOREIGN KEY ([RRaceCardId]) REFERENCES [dbo].[RaceCard] ([ID]);
  
  
  GO
  PRINT N'Creating [dbo].[FK_Records_system]...';
  
  
  GO
  ALTER TABLE [dbo].[Records]
      ADD CONSTRAINT [FK_Records_system] FOREIGN KEY ([systemID]) REFERENCES [dbo].[system] ([ID]);
  
  
  GO
  PRINT N'Creating [dbo].[Place-view]...';
  
  
  GO
  CREATE VIEW [dbo].[Place-view]
  AS 
  
  SELECT 
  
      rc.RaceDate, 
      c.name AS course,
      h.name AS horse,
      p.PPrice05Min
  
  FROM RaceCard rc 
  JOIN PlacePrice p
  ON rc.ID=p.ID
  
  LEFT JOIN course c ON c.ID = rc.courseID 
  LEFT JOIN horse h ON h.ID = rc.horseID
  GO
  PRINT N'Creating [dbo].[fn_ConvertDistanceStringToMeters]...';
  
  
  GO
  
  CREATE FUNCTION [dbo].[fn_ConvertDistanceStringToMeters](@distStr nvarchar(300)) RETURNS float
  BEGIN
  
  	/* 
  		returns the equivalent in meters of a distance string expressed in miles and furlongs
  		
  	*/
  
  
  	declare @miles float = 0
  	declare @furlongs float = 0
  
  	SET @distStr = lower(@distStr)
  	
  	declare @furlongStr varchar(399) = @distStr
  
  	declare @idx int = charindex (N'm', @distStr)
  	if @idx> 0
  		begin
  			declare @milesStr nvarchar(300) = substring(@DistStr, 1, @idx - 1)
  			SET @miles = try_convert(float, @milesStr)
  			SET @furlongStr =  substring(@DistStr, @idx + 1, len(@DistStr))
  		end
  
  	-- at this point @furlongStr contains an extraction of furlongs from @distStr 
  	-- if @distStr also contained miles, it was removed otherwise it just has an untouched copy of @distStr
  
  	set @idx = charindex (N'f', @distStr)
  	if @idx> 0
  		begin
  			-- extract fraction indicator, if any
  			declare @fract_idx int = charindex( N'½', lower(@furlongStr)) + charindex( N'¼', lower(@furlongStr)) + charindex( N'¾', lower(@furlongStr))
  			if @fract_idx>0
  				begin
  					declare @fract_str varchar(300) = substring(@furlongStr,@fract_idx, 1)
  					set  @furlongs = @furlongs +
  						case 
  							when @fract_str = N'¼' then 0.25
  							when @fract_str = N'½' then 0.5
  							when @fract_str = N'¾' then 0.75
  							else 0
  						end
  					-- remove fraction from @furlongStr, leaving a string of the format '##f', where ## is an integer number
  					-- of a string with only an f, meaning there's no integer part to the furloong expression
  					set @furlongStr =  replace(replace(replace(@furlongStr, N'¼',''),N'½',''), N'¾', '')
  				end
  			if len(@furlongStr) > 1
  				begin
  					declare @int_furlongs float = try_convert(float, substring(@furlongStr, 1, charindex (N'f', @furlongStr)-1))
  					if @int_furlongs is not null set @furlongs = @furlongs + @int_furlongs
  				end
  		end
  
  	return @miles * 1609.34 + @furlongs * 201.168
      
  END;
  GO
  PRINT N'Creating [dbo].[fn_ConvertStonesAndPoundsStringToKgs]...';
  
  
  GO
  CREATE FUNCTION [dbo].[fn_ConvertStonesAndPoundsStringToKgs](@intStr nvarchar(300)) RETURNS float
  BEGIN
  
  	/* 
  		returns the equivalent in Kilograms of a weight expressed as string of the form SS-PP
  		where SS is stones and pp is pounds
  	
  	*/
  
  
  	declare @stones float = 0
  	declare @pounds float = 0
  
  	SET @intStr = rtrim(ltrim(lower(@intStr)))
  
  	declare @dashIdx int = charindex('-',@intStr)
  	if @dashIdx=0
  		begin
  			-- no - separating stones and pounds, assume the string only contains stones and no pounds at all
  			set @stones = try_convert(float,@intStr)
  			if @stones is null set @stones = 0;
  		end
  	else
  		begin
  			set @stones =  try_convert(float,substring(@intStr, 1, @dashIdx-1))
  			if @stones is null set @stones = 0;
  			set @pounds =  try_convert(float,substring(@intStr, @dashIdx+1, len(@intStr)))
  			if @pounds is null set @pounds = 0;
  		end
  
  	return @stones *  6.35029 + @pounds * 0.4536
      
  END;
  GO
  PRINT N'Creating [dbo].[fn_GetAvgTickDrop]...';
  
  
  GO
  
  CREATE FUNCTION [dbo].[fn_GetAvgTickDrop](@HId BIGINT, @RDate date) RETURNS float
  BEGIN
  
  	DECLARE @retVal float;
  	SELECT @retVal = AVG(TickDrop) FROM (SELECT 
  	(SELECT Tick FROM tick_equivalence WHERE Price = (SELECT MAX(Price) FROM tick_equivalence WHERE Price<=BFSP)) - 
  	(SELECT Tick FROM tick_equivalence WHERE Price = (SELECT MAX(Price) FROM tick_equivalence WHERE Price<=IPMin))  AS TickDrop
  	FROM RaceCard 
  	WHERE horseID = @HId AND RaceDate < @RDate) B;
  RETURN @retVal;
  END;
  GO
  PRINT N'Creating [dbo].[fn_WinningDistanceStringToMeters]...';
  
  
  GO
  CREATE FUNCTION [dbo].[fn_WinningDistanceStringToMeters](@intStr varchar(10)) 
  RETURNS float
  BEGIN
  
  	/* 
  		returns the equivalent in meters of a winning distance expressed in heads, body lengths, etc.
  		
  	*/
  
  	if @intStr is null
  		return null
  
  	declare @meters float = null
  	declare @winDistStr varchar(19) = rtrim(ltrim(lower(@intStr)))
  
  	-- remove any values values in parenthesis - they are notes
  	declare @openParenthesis int = charindex('(',@winDistStr)
  	declare @closeParenthesis int = charindex(')',@winDistStr)
  	if @openParenthesis>0 and @closeParenthesis>0
  	set @winDistStr = left(@winDistStr, @openParenthesis-1) + substring(@winDistStr, @closeParenthesis+1, len(@winDistStr))
  	if @winDistStr in ('dht', 'hd', 'nk', 'nse', 'shd', 'sht-hd', 'snk' )
  		-- distance in expressed as horse length 
  		set @meters = case @winDistStr
  							when 'dht' then 0           -- dead heat
  							when'hd'then  0.40			-- head
  							when 'nk'then 0.72			-- neck
  							when 'nse' then 0.12		-- nose
  							when 'shd'then  0.24		-- short head
  							when 'sht-hd' then 0.24		-- short head
  							when 'snk' then 0.54		-- short neck
  						end		
  	else
  		begin
  			-- distance expressed in horse-length (a horse length=2.4 m). May have fractional parts to it (such as ½, etc)
  			declare @fract_idx int = charindex(N'½', @winDistStr) + charindex(N'¼', @winDistStr) + charindex(N'¾', @winDistStr)
  			if @fract_idx=0
  				set @meters = 0
  			else
  				begin
  					set @meters =  case 
  										when substring(@winDistStr,@fract_idx, 1)= N'½' then 0.5
  										when substring(@winDistStr,@fract_idx, 1)= N'¼' then 0.25
  										when substring(@winDistStr,@fract_idx, 1)= N'¾' then 0.75
  										else 0
  									end
  					set @winDistStr = left(@winDistStr,@fract_idx-1) 
  				end
  			declare @horses int = try_convert(int,@winDistStr)
  			if @horses is not null
  					set @meters = (@meters + abs(@horses)) * 2.4
  		end	
  			
  	return @meters
  	
  END
  GO
  PRINT N'Creating [dbo].[TR_INSTEADOFINSERT_distance]...';
  
  
  GO
  CREATE TRIGGER [dbo].[TR_INSTEADOFINSERT_distance]
     ON [dbo].[distance]
      INSTEAD OF INSERT
     AS 
        BEGIN
  
           SET  NOCOUNT  ON
  
  		-- do some basic error checking
  		 if (SELECT COUNT(*) FROM Inserted WHERE Name='' OR Name IS NULL)>0
  			begin
  				raiserror('Name cannot be empty or null', 16, 1)
  				return
  			end
  		
  		 -- create a temporary table to hold values that do not have meters and furlongs
  		 select * into #CalculatedInserts
  		 from inserted
  
  		 -- if Meters is not provided in the insertion, we calculate the value
  		 UPDATE #CalculatedInserts
  			SET Meters = dbo.fn_ConvertDistanceStringToMeters(Name)
  		 WHERE Meters IS NULL
  
  		 -- if Furlongs is not provided in the insertion, we calculate the value
  		 UPDATE #CalculatedInserts
  			SET Furlongs = Meters * 0.00497096
  		 WHERE Furlongs IS NULL
  		 
  		 -- request the insertion 
  		 INSERT INTO dbo.distance
  			SELECT  Name, Meters, Furlongs FROM #CalculatedInserts
  
        END
  GO
  PRINT N'Creating [dbo].[TR_INSTEADOFUPDATE_distance]...';
  
  
  GO
  CREATE TRIGGER [dbo].[TR_INSTEADOFUPDATE_distance]
     ON [dbo].[distance]
      INSTEAD OF UPDATE
     AS 
        BEGIN
  		
          SET  NOCOUNT  ON
  
  	    -- do some basic error checking
  		if (SELECT COUNT(*) FROM Inserted WHERE Name='' OR Name IS NULL)>0
  		begin
  			raiserror('Name cannot be empty or null', 16, 1)
  			return
  		end
  
  		-- create a temporary table to hold values, we may modify this table
  		-- with calculated meters and furlongs and it'll be the tables inserts come from
  		select * into #CalculatedInserts
  		from inserted
  
  		--select * from #CalculatedInserts
  		--select * from deleted
  
  
  		if update(Name)
  			begin
  
  					-- if Meters is not provided in the insertion, we calculate the value
  					UPDATE #CalculatedInserts
  						SET #CalculatedInserts.Meters = dbo.fn_ConvertDistanceStringToMeters(#CalculatedInserts.Name)
  					FROM #CalculatedInserts INNER JOIN Deleted ON #CalculatedInserts.Id = Deleted.Id
  					WHERE #CalculatedInserts.Name <> Deleted.Name
  
  					-- select * from #CalculatedInserts
  
  					-- if Furlongs is not provided in the insertion, we calculate the value
  					UPDATE #CalculatedInserts
  						SET #CalculatedInserts.Furlongs = #CalculatedInserts.Meters * 0.00497096
  					FROM #CalculatedInserts INNER JOIN Deleted ON #CalculatedInserts.Id = Deleted.Id
  					WHERE #CalculatedInserts.Name <> Deleted.Name
  
  					-- select * from #CalculatedInserts
  
  			end
  		
  		-- request the update 
  		update dbo.distance SET 
  			Name = I.Name,
  			Meters = I.Meters,
  			Furlongs = I.Furlongs
  		from dbo.distance M
  			inner join #CalculatedInserts I on I.Id = M.Id
  
        END
  GO
  PRINT N'Creating [dbo].[RaceCard-view]...';
  
  
  GO
  CREATE VIEW [dbo].[RaceCard-view]
  AS
  SELECT 
  
      rc.RaceDate, 
      c.name AS course,
      h.name AS horse,
      FORMAT(dbo.fn_GetAvgTickDrop(rc.horseID, rc.RaceDate),'0.00') AS AvgTickDrop
  
  FROM RaceCard rc 
  LEFT JOIN course c ON c.ID = rc.courseID 
  LEFT JOIN horse h ON h.ID = rc.horseID
  GO
  PRINT N'Creating [dbo].[distance].[MS_SSMA_SOURCE]...';
  
  
  GO
  EXECUTE sp_addextendedproperty @name = N'MS_SSMA_SOURCE', @value = N'HorseRacing.`distance`', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'distance';
  
  
  GO
  PRINT N'Creating [dbo].[racetype].[MS_SSMA_SOURCE]...';
  
  
  GO
  EXECUTE sp_addextendedproperty @name = N'MS_SSMA_SOURCE', @value = N'HorseRacing.racetype', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'racetype';
  
  
  GO
  /*
  Post-Deployment Script Template							
  --------------------------------------------------------------------------------------
   This file contains SQL statements that will be appended to the build script.		
   Use SQLCMD syntax to include a file in the post-deployment script.			
   Example:      :r .\myfile.sql								
   Use SQLCMD syntax to reference a variable in the post-deployment script.		
   Example:      :setvar TableName MyTable							
                 SELECT * FROM [$(TableName)]					
  --------------------------------------------------------------------------------------
  */
  
  
  SET IDENTITY_INSERT [dbo].[bid] ON
  INSERT INTO [dbo].[bid] ([ID], [Name]) VALUES (1, N'back')
  INSERT INTO [dbo].[bid] ([ID], [Name]) VALUES (2, N'lay')
  SET IDENTITY_INSERT [dbo].[bid] OFF
  GO
  
  SET IDENTITY_INSERT [dbo].[going] ON
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (12, N'FRM')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (7, N'GD')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (10, N'GTF')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (1, N'GTS')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (13, N'GTY')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (6, N'HTS')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (3, N'HVY')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (2, N'SFT')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (8, N'SLW')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (4, N'STD')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (19, N'STFA')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (17, N'STFI')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (15, N'STG')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (16, N'STHE')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (18, N'STSF')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (5, N'STSL')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (9, N'YLD')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (14, N'YTG')
  INSERT INTO [dbo].[going] ([ID], [Name]) VALUES (11, N'YTS')
  SET IDENTITY_INSERT [dbo].[going] OFF
  GO
  
  
  SET IDENTITY_INSERT [dbo].[country] ON
  INSERT INTO [dbo].[country] ([ID], [Name]) VALUES (1, N'GB')
  INSERT INTO [dbo].[country] ([ID], [Name]) VALUES (2, N'IE')
  SET IDENTITY_INSERT [dbo].[country] OFF
  GO
  
  SET IDENTITY_INSERT [dbo].[outcome] ON
  INSERT INTO [dbo].[outcome] ([ID], [Name]) VALUES (1, N'win')
  INSERT INTO [dbo].[outcome] ([ID], [Name]) VALUES (2, N'loss')
  SET IDENTITY_INSERT [dbo].[outcome] OFF
  GO
  
  SET IDENTITY_INSERT [dbo].[headgear] ON
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (5, N'B')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (17, N'BC')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (3, N'C')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (16, N'E')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (12, N'EB')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (15, N'ET')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (1, N'H')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (10, N'HB')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (11, N'HC')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (14, N'HE')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (8, N'HT')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (13, N'HV')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (2, N'T')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (9, N'TB')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (4, N'TC')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (6, N'TV')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (7, N'V')
  INSERT INTO [dbo].[headgear] ([ID], [Name]) VALUES (18, N'VC')
  SET IDENTITY_INSERT [dbo].[headgear] OFF
  GO
  
  SET IDENTITY_INSERT [dbo].[course] ON
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (1, N'ASCOT', N'Ascot')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (2, N'AINTREE', N'Aint')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (3, N'AYR', N'Ayr')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (4, N'BANGOR-ON-DEE', NULL)
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (5, N'CATTERICK', N'Catt')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (6, N'CHELTENHAM', N'Chelt')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (7, N'CHEPSTOW', N'Chep')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (8, N'CLONMEL', N'Clon')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (9, N'CORK', N'Cork')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (10, N'DONCASTER', N'Donc')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (11, N'DOWN ROYAL', N'DownR')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (12, N'DUNDALK', N'Dund')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (13, N'EXETER', N'Extr')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (14, N'FAIRYHOUSE', N'Fairy')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (15, N'FAKENHAM', N'Fake')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (16, N'FONTWELL', N'Font')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (17, N'GOWRAN PARK', N'GowP')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (18, N'GREAT LEIGHS', NULL)
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (19, N'HAYDOCK', N'Hayd')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (20, N'HEREFORD', N'Here')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (21, N'HUNTINGDON', N'Hunt')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (22, N'KELSO', N'Kelso')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (23, N'KEMPTON', N'Kemp')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (24, N'LEICESTER', N'Leic')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (25, N'LINGFIELD', N'Ling')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (26, N'LUDLOW', N'Ludl')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (27, N'MARKET RASEN', N'MrktR')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (28, N'MUSSELBURGH', N'Muss')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (29, N'NAAS', N'Naas')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (30, N'NAVAN', N'Navan')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (31, N'NEWBURY', N'Newb')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (32, N'NEWCASTLE', N'Newc')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (33, N'PLUMPTON', N'Plump')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (34, N'PUNCHESTOWN', N'Punch')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (35, N'SANDOWN', N'Sand')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (36, N'SEDGEFIELD', N'Sedge')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (37, N'SOUTHWELL', N'Sthl')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (38, N'TAUNTON', N'Taun')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (39, N'THURLES', N'Thurl')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (40, N'TRAMORE', N'Tram')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (41, N'UTTOXETER', N'Uttox')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (42, N'WARWICK', N'Warw')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (43, N'WETHERBY', N'Weth')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (44, N'WINCANTON', N'Winc')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (45, N'WOLVERHAMPTON', N'Wolv')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (46, N'CARLISLE', N'Carl')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (47, N'FFOS LAS', N'FfosL')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (48, N'LEOPARDSTOWN', N'Leop')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (49, N'TOWCESTER', N'Towc')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (50, N'BATH', N'Bath')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (51, N'DOWNPATRICK', N'DownP')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (52, N'HEXHAM', N'Hex')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (53, N'LIMERICK', N'Lim')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (54, N'WEXFORD', N'Wex')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (55, N'BALLINROBE', N'Ballin')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (56, N'BEVERLEY', N'Bev')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (57, N'BRIGHTON', N'Brig')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (58, N'EPSOM', N'Epsm')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (59, N'KILBEGGAN', N'Kilb')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (60, N'NEWMARKET', N'Newm')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (61, N'NEWTON ABBOT', N'Newt')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (62, N'NOTTINGHAM', N'Nott')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (63, N'PERTH', N'Perth')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (64, N'PONTEFRACT', N'Ponte')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (65, N'RIPON', N'Ripon')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (66, N'SALISBURY', N'Salis')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (67, N'STRATFORD', N'Strat')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (68, N'THIRSK', N'Thirsk')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (69, N'WINDSOR', N'Wind')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (70, N'YARMOUTH', N'Yarm')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (71, N'CARTMEL', N'Cart')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (72, N'CHESTER', N'Chest')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (73, N'CURRAGH', NULL)
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (74, N'GOODWOOD', N'Good')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (75, N'HAMILTON', N'Ham')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (76, N'KILLARNEY', N'Killar')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (77, N'REDCAR', N'Redc')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (78, N'ROSCOMMON', N'Rosc')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (79, N'SLIGO', N'Sligo')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (80, N'TIPPERARY', N'Tipp')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (81, N'WORCESTER', N'Worc')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (82, N'YORK', N'York')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (83, N'LISTOWEL', N'List')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (84, N'BELLEWSTOWN', N'Belle')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (85, N'GALWAY', N'Gal')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (86, N'LAYTOWN', N'Layt')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (92, N'Bangor', N'Bang')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (100, N'Chelmsford City', N'ChelmC')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (108, N'Folkstone', N'Folk')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (170, N'Shelbourne', N'Shelb')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (175, N'Tralee', N'Tral')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (178, N'Royal Ascot', N'Royal Ascot')
  INSERT INTO [dbo].[course] ([ID], [Name], [BFEquivalence]) VALUES (179, N'FOLKESTONE', N'FOLKESTONE')
  SET IDENTITY_INSERT [dbo].[course] OFF
  GO
  
  SET IDENTITY_INSERT [dbo].[tick_equivalence] ON
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (351, 1000, 1, 0.1)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (352, 990, 2, 0.10101)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (353, 980, 3, 0.102041)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (354, 970, 4, 0.103093)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (355, 960, 5, 0.104167)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (356, 950, 6, 0.105263)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (357, 940, 7, 0.106383)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (358, 930, 8, 0.107527)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (359, 920, 9, 0.108696)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (360, 910, 10, 0.10989)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (361, 900, 11, 0.111111)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (362, 890, 12, 0.11236)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (363, 880, 13, 0.113636)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (364, 870, 14, 0.114943)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (365, 860, 15, 0.116279)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (366, 850, 16, 0.117647)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (367, 840, 17, 0.119048)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (368, 830, 18, 0.120482)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (369, 820, 19, 0.121951)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (370, 810, 20, 0.123457)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (371, 800, 21, 0.125)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (372, 790, 22, 0.126582)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (373, 780, 23, 0.128205)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (374, 770, 24, 0.12987)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (375, 760, 25, 0.131579)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (376, 750, 26, 0.133333)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (377, 740, 27, 0.135135)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (378, 730, 28, 0.136986)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (379, 720, 29, 0.138889)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (380, 710, 30, 0.140845)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (381, 700, 31, 0.142857)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (382, 690, 32, 0.144928)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (383, 680, 33, 0.147059)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (384, 670, 34, 0.149254)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (385, 660, 35, 0.151515)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (386, 650, 36, 0.153846)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (387, 640, 37, 0.15625)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (388, 630, 38, 0.15873)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (389, 620, 39, 0.16129)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (390, 610, 40, 0.163934)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (391, 600, 41, 0.166667)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (392, 590, 42, 0.169492)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (393, 580, 43, 0.172414)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (394, 570, 44, 0.175439)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (395, 560, 45, 0.178571)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (396, 550, 46, 0.181818)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (397, 540, 47, 0.185185)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (398, 530, 48, 0.188679)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (399, 520, 49, 0.192308)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (400, 510, 50, 0.196078)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (401, 500, 51, 0.2)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (402, 490, 52, 0.204082)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (403, 480, 53, 0.208333)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (404, 470, 54, 0.212766)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (405, 460, 55, 0.217391)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (406, 450, 56, 0.222222)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (407, 440, 57, 0.227273)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (408, 430, 58, 0.232558)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (409, 420, 59, 0.238095)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (410, 410, 60, 0.243902)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (411, 400, 61, 0.25)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (412, 390, 62, 0.25641)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (413, 380, 63, 0.263158)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (414, 370, 64, 0.27027)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (415, 360, 65, 0.277778)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (416, 350, 66, 0.285714)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (417, 340, 67, 0.294118)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (418, 330, 68, 0.30303)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (419, 320, 69, 0.3125)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (420, 310, 70, 0.322581)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (421, 300, 71, 0.333333)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (422, 290, 72, 0.344828)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (423, 280, 73, 0.357143)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (424, 270, 74, 0.37037)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (425, 260, 75, 0.384615)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (426, 250, 76, 0.4)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (427, 240, 77, 0.416667)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (428, 230, 78, 0.434783)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (429, 220, 79, 0.454545)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (430, 210, 80, 0.47619)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (431, 200, 81, 0.5)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (432, 190, 82, 0.526316)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (433, 180, 83, 0.555556)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (434, 170, 84, 0.588235)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (435, 160, 85, 0.625)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (436, 150, 86, 0.666667)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (437, 140, 87, 0.714286)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (438, 130, 88, 0.769231)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (439, 120, 89, 0.833333)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (440, 110, 90, 0.909091)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (441, 100, 91, 1)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (442, 95, 92, 1.05263)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (443, 90, 93, 1.11111)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (444, 85, 94, 1.17647)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (445, 80, 95, 1.25)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (446, 75, 96, 1.33333)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (447, 70, 97, 1.42857)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (448, 65, 98, 1.53846)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (449, 60, 99, 1.66667)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (450, 55, 100, 1.81818)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (451, 50, 101, 2)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (452, 48, 102, 2.08333)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (453, 46, 103, 2.17391)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (454, 44, 104, 2.27273)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (455, 42, 105, 2.38095)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (456, 40, 106, 2.5)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (457, 38, 107, 2.63158)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (458, 36, 108, 2.77778)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (459, 34, 109, 2.94118)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (460, 32, 110, 3.125)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (461, 30, 111, 3.33333)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (462, 29, 112, 3.44828)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (463, 28, 113, 3.57143)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (464, 27, 114, 3.7037)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (465, 26, 115, 3.84615)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (466, 25, 116, 4)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (467, 24, 117, 4.16667)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (468, 23, 118, 4.34783)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (469, 22, 119, 4.54545)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (470, 21, 120, 4.7619)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (471, 20, 121, 5)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (472, 19.5, 122, 5.12821)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (473, 19, 123, 5.26316)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (474, 18.5, 124, 5.40541)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (475, 18, 125, 5.55556)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (476, 17.5, 126, 5.71429)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (477, 17, 127, 5.88235)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (478, 16.5, 128, 6.06061)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (479, 16, 129, 6.25)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (480, 15.5, 130, 6.45161)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (481, 15, 131, 6.66667)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (482, 14.5, 132, 6.89655)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (483, 14, 133, 7.14286)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (484, 13.5, 134, 7.40741)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (485, 13, 135, 7.69231)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (486, 12.5, 136, 8)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (487, 12, 137, 8.33333)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (488, 11.5, 138, 8.69565)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (489, 11, 139, 9.09091)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (490, 10.5, 140, 9.52381)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (491, 10, 141, 10)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (492, 9.8, 142, 10.2041)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (493, 9.6, 143, 10.4167)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (494, 9.4, 144, 10.6383)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (495, 9.2, 145, 10.8696)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (496, 9, 146, 11.1111)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (497, 8.8, 147, 11.3636)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (498, 8.6, 148, 11.6279)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (499, 8.4, 149, 11.9048)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (500, 8.2, 150, 12.1951)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (501, 8, 151, 12.5)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (502, 7.8, 152, 12.8205)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (503, 7.6, 153, 13.1579)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (504, 7.4, 154, 13.5135)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (505, 7.2, 155, 13.8889)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (506, 7, 156, 14.2857)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (507, 6.8, 157, 14.7059)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (508, 6.6, 158, 15.1515)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (509, 6.4, 159, 15.625)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (510, 6.2, 160, 16.129)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (511, 6, 161, 16.6667)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (512, 5.9, 162, 16.9492)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (513, 5.8, 163, 17.2414)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (514, 5.7, 164, 17.5439)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (515, 5.6, 165, 17.8571)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (516, 5.5, 166, 18.1818)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (517, 5.4, 167, 18.5185)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (518, 5.3, 168, 18.8679)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (519, 5.2, 169, 19.2308)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (520, 5.1, 170, 19.6078)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (521, 5, 171, 20)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (522, 4.9, 172, 20.4082)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (523, 4.8, 173, 20.8333)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (524, 4.7, 174, 21.2766)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (525, 4.6, 175, 21.7391)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (526, 4.5, 176, 22.2222)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (527, 4.4, 177, 22.7273)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (528, 4.3, 178, 23.2558)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (529, 4.2, 179, 23.8095)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (530, 4.1, 180, 24.3902)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (531, 4, 181, 25)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (532, 3.95, 182, 25.3165)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (533, 3.9, 183, 25.641)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (534, 3.85, 184, 25.974)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (535, 3.8, 185, 26.3158)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (536, 3.75, 186, 26.6667)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (537, 3.7, 187, 27.027)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (538, 3.65, 188, 27.3973)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (539, 3.6, 189, 27.7778)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (540, 3.55, 190, 28.169)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (541, 3.5, 191, 28.5714)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (542, 3.45, 192, 28.9855)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (543, 3.4, 193, 29.4118)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (544, 3.35, 194, 29.8507)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (545, 3.3, 195, 30.303)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (546, 3.25, 196, 30.7692)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (547, 3.2, 197, 31.25)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (548, 3.15, 198, 31.746)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (549, 3.1, 199, 32.2581)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (550, 3.05, 200, 32.7869)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (551, 3, 201, 33.3333)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (552, 2.98, 202, 33.557)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (553, 2.96, 203, 33.7838)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (554, 2.94, 204, 34.0136)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (555, 2.92, 205, 34.2466)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (556, 2.9, 206, 34.4828)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (557, 2.88, 207, 34.7222)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (558, 2.86, 208, 34.965)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (559, 2.84, 209, 35.2113)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (560, 2.82, 210, 35.461)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (561, 2.8, 211, 35.7143)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (562, 2.78, 212, 35.9712)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (563, 2.76, 213, 36.2319)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (564, 2.74, 214, 36.4963)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (565, 2.72, 215, 36.7647)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (566, 2.7, 216, 37.037)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (567, 2.68, 217, 37.3134)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (568, 2.66, 218, 37.594)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (569, 2.64, 219, 37.8788)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (570, 2.62, 220, 38.1679)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (571, 2.6, 221, 38.4615)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (572, 2.58, 222, 38.7597)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (573, 2.56, 223, 39.0625)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (574, 2.54, 224, 39.3701)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (575, 2.52, 225, 39.6825)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (576, 2.5, 226, 40)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (577, 2.48, 227, 40.3226)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (578, 2.46, 228, 40.6504)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (579, 2.44, 229, 40.9836)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (580, 2.42, 230, 41.3223)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (581, 2.4, 231, 41.6667)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (582, 2.38, 232, 42.0168)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (583, 2.36, 233, 42.3729)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (584, 2.34, 234, 42.735)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (585, 2.32, 235, 43.1034)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (586, 2.3, 236, 43.4783)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (587, 2.28, 237, 43.8596)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (588, 2.26, 238, 44.2478)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (589, 2.24, 239, 44.6429)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (590, 2.22, 240, 45.045)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (591, 2.2, 241, 45.4545)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (592, 2.18, 242, 45.8716)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (593, 2.16, 243, 46.2963)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (594, 2.14, 244, 46.729)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (595, 2.12, 245, 47.1698)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (596, 2.1, 246, 47.619)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (597, 2.08, 247, 48.0769)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (598, 2.06, 248, 48.5437)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (599, 2.04, 249, 49.0196)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (600, 2.02, 250, 49.505)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (601, 2, 251, 50)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (602, 1.99, 252, 50.2513)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (603, 1.98, 253, 50.5051)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (604, 1.97, 254, 50.7614)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (605, 1.96, 255, 51.0204)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (606, 1.95, 256, 51.2821)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (607, 1.94, 257, 51.5464)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (608, 1.93, 258, 51.8135)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (609, 1.92, 259, 52.0833)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (610, 1.91, 260, 52.356)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (611, 1.9, 261, 52.6316)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (612, 1.89, 262, 52.9101)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (613, 1.88, 263, 53.1915)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (614, 1.87, 264, 53.4759)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (615, 1.86, 265, 53.7634)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (616, 1.85, 266, 54.0541)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (617, 1.84, 267, 54.3478)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (618, 1.83, 268, 54.6448)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (619, 1.82, 269, 54.9451)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (620, 1.81, 270, 55.2486)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (621, 1.8, 271, 55.5556)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (622, 1.79, 272, 55.8659)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (623, 1.78, 273, 56.1798)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (624, 1.77, 274, 56.4972)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (625, 1.76, 275, 56.8182)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (626, 1.75, 276, 57.1429)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (627, 1.74, 277, 57.4713)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (628, 1.73, 278, 57.8035)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (629, 1.72, 279, 58.1395)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (630, 1.71, 280, 58.4795)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (631, 1.7, 281, 58.8235)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (632, 1.69, 282, 59.1716)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (633, 1.68, 283, 59.5238)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (634, 1.67, 284, 59.8802)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (635, 1.66, 285, 60.241)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (636, 1.65, 286, 60.6061)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (637, 1.64, 287, 60.9756)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (638, 1.63, 288, 61.3497)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (639, 1.62, 289, 61.7284)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (640, 1.61, 290, 62.1118)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (641, 1.6, 291, 62.5)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (642, 1.59, 292, 62.8931)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (643, 1.58, 293, 63.2911)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (644, 1.57, 294, 63.6943)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (645, 1.56, 295, 64.1026)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (646, 1.55, 296, 64.5161)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (647, 1.54, 297, 64.9351)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (648, 1.53, 298, 65.3595)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (649, 1.52, 299, 65.7895)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (650, 1.51, 300, 66.2252)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (651, 1.5, 301, 66.6667)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (652, 1.49, 302, 67.1141)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (653, 1.48, 303, 67.5676)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (654, 1.47, 304, 68.0272)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (655, 1.46, 305, 68.4931)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (656, 1.45, 306, 68.9655)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (657, 1.44, 307, 69.4444)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (658, 1.43, 308, 69.9301)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (659, 1.42, 309, 70.4225)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (660, 1.41, 310, 70.922)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (661, 1.4, 311, 71.4286)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (662, 1.39, 312, 71.9424)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (663, 1.38, 313, 72.4638)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (664, 1.37, 314, 72.9927)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (665, 1.36, 315, 73.5294)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (666, 1.35, 316, 74.0741)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (667, 1.34, 317, 74.6269)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (668, 1.33, 318, 75.188)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (669, 1.32, 319, 75.7576)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (670, 1.31, 320, 76.3359)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (671, 1.3, 321, 76.9231)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (672, 1.29, 322, 77.5194)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (673, 1.28, 323, 78.125)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (674, 1.27, 324, 78.7402)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (675, 1.26, 325, 79.3651)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (676, 1.25, 326, 80)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (677, 1.24, 327, 80.6452)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (678, 1.23, 328, 81.3008)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (679, 1.22, 329, 81.9672)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (680, 1.21, 330, 82.6446)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (681, 1.2, 331, 83.3333)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (682, 1.19, 332, 84.0336)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (683, 1.18, 333, 84.7458)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (684, 1.17, 334, 85.4701)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (685, 1.16, 335, 86.2069)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (686, 1.15, 336, 86.9565)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (687, 1.14, 337, 87.7193)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (688, 1.13, 338, 88.4956)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (689, 1.12, 339, 89.2857)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (690, 1.11, 340, 90.0901)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (691, 1.1, 341, 90.9091)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (692, 1.09, 342, 91.7431)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (693, 1.08, 343, 92.5926)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (694, 1.07, 344, 93.4579)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (695, 1.06, 345, 94.3396)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (696, 1.05, 346, 95.2381)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (697, 1.04, 347, 96.1538)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (698, 1.03, 348, 97.0874)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (699, 1.02, 349, 98.0392)
  INSERT INTO [dbo].[tick_equivalence] ([ID], [Price], [Tick], [Percent]) VALUES (700, 1.01, 350, 99.0099)
  SET IDENTITY_INSERT [dbo].[tick_equivalence] OFF
  GO
  
  SET IDENTITY_INSERT [dbo].[racetype] ON
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (1, N'Maiden/Hurdle', N'Mdn Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (2, N'Hurdle', N'Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (3, N'Handicap/Hurdle', N'Hcap Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (4, N'Handicap/Chase', N'Hcap Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (5, N'Chase', N'Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (6, N'Standard', N'Std')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (7, N'Handicap-Flat', N'Hcap Flat')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (8, N'Maiden-Flat', N'Mdn Flat')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (9, N'Handicap/Maiden', N'Hcap Mdn')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (10, N'Maiden/Chase', N'Mdn Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (11, N'Flat', N'Flat')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (12, N'Maiden', N'Mdn')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (13, N'Handicap', N'Hcap')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (16, N'Listed Race', N'List')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (17, N'Group 1', N'Grp1')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (18, N'Group 2', N'Grp2')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (19, N'Group 3', N'Grp3')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (20, N'Maiden Stakes', N'Mdn Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (21, N'Selling Stakes', N'Sell Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (22, N'Claiming Stakes', N'Claim Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (23, N'Rated Stakes', N'Hcap')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (24, N'Classified Stakes', N'Class Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (25, N'Nursery Handicap', N'Nursery Hcap')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (27, N'Showcase Handicap', N'Hcap')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (29, N'Stakes', N'Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (32, N'Hunters', N'Hunt')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (33, N'Novice', N'Nov')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (34, N'Selling', N'Sell')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (35, N'Claiming', N'Claim')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (36, N'Classified', N'Class')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (37, N'Beginners', N'Beg')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (38, N'National Hunt Flat', N'NHF')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (39, N'Irish NH Flat', N'INHF')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (41, N'Novice/Hurdle', N'Nov Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (42, N'Novice/Chase', N'Nov Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (43, N'Listed Race/Novice/Hurdle', N'List Nov Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (44, N'Grd2/Novice/Chase', N'Grd2 Nov Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (45, N'Grd2', N'Grd2')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (46, N'Grd3/Handicap/Chase', N'Grd3 Hcap Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (47, N'Grd3', N'Grd3')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (48, N'Grd2/Hurdle', N'Grd2 Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (49, N'Listed Race/National Hunt Flat', N'List NHF')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (50, N'Beginners/Chase', N'Beg Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (51, N'Maiden/National Hunt Flat', N'Mdn NHF')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (52, N'Juv/Hurdle', N'Juv Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (53, N'Juv', N'Juv')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (54, N'Novice/Handicap/Chase', N'Nov Hcap Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (55, N'Stakes/National Hunt Flat', N'Stks NHF')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (56, N'Listed Race/Hurdle', N'List Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (57, N'Grd1/Novice/Hurdle', N'Grd1 Nov Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (58, N'Grd1', N'Grd1')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (59, N'Novice/Handicap/Hurdle', N'Nov Hcap Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (60, N'Maiden/Handicap', N'Mdn Hcap')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (61, N'App/Handicap', N'App Hcap')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (62, N'App', N'App')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (63, N'Cond/Stakes', N'Cond Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (64, N'Cond', N'Cond')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (65, N'Hunters/Chase', N'Hunt Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (66, N'Cond/Handicap/Hurdle', N'Cond Hcap Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (67, N'Listed Race/Chase', N'List Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (68, N'Listed Race/Handicap/Hurdle', N'List Hcap Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (69, N'Listed Race/Novice/Chase', N'List Nov Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (70, N'Grad/Chase', N'Grad Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (71, N'Grad', N'Grad')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (72, N'Juv/Maiden/Hurdle', N'Juv Mdn Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (73, N'Grd2/Juv/Hurdle', N'Grd2 Juv Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (74, N'Grd1/Chase', N'Grd1 Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (75, N'Grd2/Chase', N'Grd2 Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (76, N'XC/Handicap/Chase', N'XC Hcap Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (77, N'XC', N'XC')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (78, N'Grd2/Novice/Hurdle', N'Grd2 Nov Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (79, N'Listed Race/Juv/Hurdle', N'List Juv Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (80, N'Grd1/Novice/Chase', N'Grd1 Nov Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (81, N'Grd3/Handicap/Hurdle', N'Grd3 Hcap Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (82, N'Listed Race/Handicap/Chase', N'List Hcap Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (83, N'Charity/Stakes', N'Charity Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (84, N'Charity', N'Charity')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (85, N'Grd1/Hurdle', N'Grd1 Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (86, N'XC/Chase', N'XC Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (87, N'Grd1/National Hunt Flat', N'Grd1 NHF')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (88, N'Grd1/Juv/Hurdle', N'Grd1 Juv Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (89, N'Selling/Hurdle', N'Sell Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (90, N'Listed Race/Stakes', N'List Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (91, N'Grd2/National Hunt Flat', N'Grd2 NHF')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (92, N'Novice/Stakes', N'Nov Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (93, N'Novice/Hunters/Chase', N'Nov Hunt Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (94, N'Juv/Handicap/Hurdle', N'Juv Hcap Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (95, N'Maiden/Hunters/Chase', N'Mdn Hunt Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (96, N'Handicap/Stakes', N'Hcap Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (97, N'PA/Handicap/Stakes', N'PA Hcap Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (98, N'PA', N'PA')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (99, N'PA/Stakes', N'PA Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (100, N'Listed Race/Handicap', N'List Hcap')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (101, N'Novice/Handicap', N'Nov Hcap')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (102, N'Nursery', N'Nursery')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (103, N'PA/Handicap', N'PA Hcap')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (104, N'PA/Group 2', N'PA Grp2')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (105, N'PA/Group 1', N'PA Grp1')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (106, N'Charity/Magnolia', N'Charity Magnolia')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (107, N'Magnolia', N'Magnolia')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (108, N'PA/Maiden/Stakes', N'PA Mdn Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (109, N'PA/3yo+', N'PA 3yo+')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (110, N'3yo+', N'3yo+')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (111, N'PA/4yo+', N'PA 4yo+')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (112, N'4yo+', N'4yo+')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (113, N'PA/Group 3', N'PA Grp3')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (114, N'App/Handicap/Stakes', N'App Hcap Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (115, N'Claiming/Chase', N'Claim Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (116, N'Grd2/Handicap/Chase', N'Grd2 Hcap Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (117, N'Handicap/Chase/Hurdle', N'Hcap Chs Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (118, N'Handicap/Hurdle/Listed Race', N'Hcap Hrd List')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (119, N'Mrd/Hurdle/Listed Race', N'Mrd Hrd List')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (120, N'Mrd', N'Mrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (121, N'Hurdle/G2', N'Hrd G2')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (122, N'G2', N'G2')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (123, N'Chase/G2', N'Chs G2')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (124, N'Mares/Chase', N'Mares Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (125, N'Mares', N'Mares')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (126, N'Grd2/Handicap/Hurdle', N'Grd2 Hcap Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (127, N'Int/Hurdle', N'Int Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (128, N'Int', N'Int')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (129, N'Mares/Hurdle', N'Mares Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (130, N'Classified/Selling/Stakes', N'Class Sell Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (131, N'National Hunt Flat/Listed Race', N'NHF List')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (132, N'National Hunt Flat/Stakes', N'NHF Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (133, N'Chase/Stakes', N'Chs Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (134, N'Novice/Handicap/Hurdle/Grd2', N'Nov Hcap Hrd Grd2')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (135, N'Selling/Chase', N'Sell Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (136, N'Listed Race/Novice/Handicap/Chase', N'List Nov Hcap Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (137, N'Novice/Selling/Hurdle', N'Nov Sell Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (138, N'Handicap/Hunters/Chase', N'Hcap Hunt Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (139, N'Selling/Handicap', N'Sell Hcap')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (140, N'Selling/Handicap/Hurdle', N'Sell Hcap Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (141, N'Claiming/Handicap', N'Claim Hcap')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (142, N'Juv/Hurdle/Listed Race', N'Juv Hrd List')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (143, N'Handicap/Chase/Listed Race', N'Hcap Chs List')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (144, N'Claiming/Hurdle', N'Claim Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (145, N'Novice/Chase/Listed Race', N'Nov Chs List')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (146, N'Int/Handicap/Hurdle', N'Int Hcap Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (147, N'Grd3/Juv/Hurdle', N'Grd3 Juv Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (148, N'Int/Juv/Hurdle', N'Int Juv Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (149, N'Novice/Listed Race/Chase', N'Nov List Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (150, N'Novice/Hurdle/Listed Race', N'Nov Hrd List')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (151, N'Mares/Novice/Hurdle', N'Mares Nov Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (152, N'Grd2/Mares/Hurdle', N'Grd2 Mares Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (153, N'Mares/Handicap/Hurdle', N'Mares Hcap Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (154, N'Mares/National Hunt Flat', N'Mares NHF')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (155, N'Novice/Grd2/Chase', N'Nov Grd2 Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (156, N'Mares/Listed Race/Chase', N'Mares List Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (157, N'Mares/Novice/Chase', N'Mares Nov Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (158, N'Mares/Handicap/Chase', N'Mares Hcap Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (159, N'Mares/Listed Race/Hurdle', N'Mares List Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (160, N'Amat/Chase', N'Amat Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (161, N'Amat', N'Amat')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (162, N'Grd3/Novice/Handicap/Hurdle', N'Grd3 Nov Hcap Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (163, N'Maiden/Handicap/Hurdle', N'Mdn Hcap Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (164, N'Grd1/Mares/Hurdle', N'Grd1 Mares Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (165, N'Grd2/Amat/Novice/Chase', N'Grd2 Amat Nov Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (166, N'Grd2/Mares/Novice/Hurdle', N'Grd2 Mares Nov Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (167, N'Amat/Handicap/Chase', N'Amat Hcap Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (168, N'Grd2/Novice/Handicap/Hurdle', N'Grd2 Nov Hcap Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (169, N'Selling/Novice/Hurdle', N'Sell Nov Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (170, N'Maiden/Hurdle/Stakes', N'Mdn Hrd Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (171, N'Mares/Maiden/National Hunt Flat', N'Mares Mdn NHF')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (172, N'Mares/Novice/Handicap/Hurdle', N'Mares Nov Hcap Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (173, N'Handicap/Novice/Chase', N'Hcap Nov Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (174, N'Listed Race/Mares/Chase', N'List Mares Chs')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (175, N'Win', N'Win')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (176, N'Cond/Selling/Hurdle', N'Cond Sell Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (177, N'Cond/Novice/Handicap/Hurdle', N'Cond Nov Hcap Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (178, N'Cond/Mares/Handicap/Hurdle', N'Cond Mares Hcap Hrd')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (179, N'Maiden/Handicap/Stakes', N'Mdn Hcap Stks')
  INSERT INTO [dbo].[racetype] ([ID], [Name], [BFEquivalence]) VALUES (180, N'Chase/Hurdle', N'Chase/Hurdle')
  SET IDENTITY_INSERT [dbo].[racetype] OFF
  GO
  
  GO
  DECLARE @VarDecimalSupported AS BIT;
  
  SELECT @VarDecimalSupported = 0;
  
  IF ((ServerProperty(N'EngineEdition') = 3)
      AND (((@@microsoftversion / power(2, 24) = 9)
            AND (@@microsoftversion & 0xffff >= 3024))
           OR ((@@microsoftversion / power(2, 24) = 10)
               AND (@@microsoftversion & 0xffff >= 1600))))
      SELECT @VarDecimalSupported = 1;
  
  IF (@VarDecimalSupported > 0)
      BEGIN
          EXECUTE sp_db_vardecimal_storage_format N'$(DatabaseName)', 'ON';
      END
  
  
  GO
  PRINT N'Update complete.';
  
  
  GO
  