Sep 22, 2013

The feature 'range index' is not yet implemented with memory optimized tables

In sql server 2014 if we will try to create a memory optimized table by following script:

CREATE TABLEtblEmployee(
     ntEmpID BIGINT PRIMARY KEY NONCLUSTERED NOT NULL,
     vcName VARCHAR(50),
     moSalary MONEY
)
WITH(MEMORY_OPTIMIZED =ON)

We may get following error message:

Msg 10771, Level 16, State 82, Line 1
The feature 'range index' is not yet implemented with memory optimized tables.
Msg 1750, Level 16, State 0, Line 1
Could not create constraint or index. See previous errors.

Cause: Sql server 2014 doesn't support range index with memory optimized tables.

Solution: Use following syntax to create memory optimized table:

CREATE TABLEtblEmployee(
     ntEmpID BIGINT NOT NULL PRIMARY KEY NONCLUSTERED HASH (ntEmpID) WITH (BUCKET_COUNT=1024),
     vcName VARCHAR(50),
     moSalary MONEY
)
WITH(MEMORY_OPTIMIZED =ON) 

Or

CREATE TABLEtblEmployee(
     ntEmpID BIGINT NOT NULL,
     vcName VARCHAR(50),
     moSalary MONEY,
     CONSTRAINT PK_sample_memoryoptimizedtable PRIMARY KEY NONCLUSTERED HASH (ntEmpID)
     WITH (BUCKET_COUNT=1024)
)

WITH(MEMORY_OPTIMIZED =ON)

No comments:

Post a Comment