Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
287 views
in Technique[技术] by (71.8m points)

How to Fix Error Msg 41337, Level 16, State 100 in Create Memory Optimize table in SQL Server

I want to use a memory optimize table and I got below error - how can I fix it? Any idea will be helpful.

Msg 41337, Level 16, State 100, Line 1
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.

Code:

CREATE TABLE dbo.Account
(  
    AccountID INT IDENTITY(1, 1) PRIMARY KEY NONCLUSTERED
) WITH (MEMORY_OPTIMIZED=ON)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

you must create a file Group first :

Create FileGroup :

imoltp is a sampledatabase

ALTER DATABASE imoltp ADD FILEGROUP imoltp_mod
    CONTAINS MEMORY_OPTIMIZED_DATA;

Add DatabaseFile To Your File Group :

ALTER DATABASE imoltp ADD FILE (
    name='imoltp_mod1', filename='c:dataimoltp_mod1')
    TO FILEGROUP imoltp_mod;

Create Memory Optimize Table:

CREATE TABLE dbo.Account(   
    AccountID INT IDENTITY(1,1) PRIMARY KEY NONCLUSTERED
    ) WITH (MEMORY_OPTIMIZED=ON)

take a look at this for get more Info : https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/creating-a-memory-optimized-table-and-a-natively-compiled-stored-procedure?view=sql-server-ver15 for more detail


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...