App Muncher

Issues faced - solutions identified - shared with community.

How i came across the problem.
I created a new DB and was creating table using the following script,

use MemDB
go
--CRATE A MEMORY OPTIMIZED TABLE
create table dbo.MemoryTable
(id integer not null primary key nonclustered hash with (BUCKET_COUNT = 1000000)
,DATE_VALUE DATETIME NULL )
WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA);



when an error Msg:41337 popped up as below.


Msg 41337, Level 16, State 100, Line 4
Cannot create memory optimized tables. To create memory optimized tables, the database must have a MEMORY_OPTIMIZED_FILEGROUP that is online and has at least one container.

Checked the DB properties and there was no File Group available in the DB as i never created it.




Solution:
I updated the query as follows:


use MemDB
GO
--CRATE A MEMORY OPTIMIZED TABLE
ALTER DATABASE MemDB
ADD Filegroup [MemDB_MEMORY] CONTAINS MEMORY_OPTIMIZED_DATA

GO
ALTER DATABASE MemDB
ADD FILE (NAME=MemDB_MEMORY, FILENAME=N'C:\Data\MemDB_MEMORY_mopt')
TO FILEGROUP [MemDB_MEMORY]

Create table dbo.MemoryTable
(id integer not null primary key nonclustered hash with (BUCKET_COUNT = 1000000)
,DATE_VALUE DATETIME NULL )
WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA);




Finally i saw the magic words..
Command(s) completed successfully.

Hope you guys will find it helpful.....

No comments:

Post a Comment

| Designed by AppMuncher