I am trying to use SQL In-Memory OLTP. The limitation is that the solution needs to be compatible with SQL Express 2019 and 2022.
This link claims that In-Memory OLTP is compatible with all versions of SQL, including Express.
With version 2022 I am not managing to get started:
EXECUTE master.dbo.xp_create_subdir 'C:\data\'
GO
ALTER DATABASE S2X ADD FILEGROUP S2x_mod
CONTAINS MEMORY_OPTIMIZED_DATA;
GO
ALTER DATABASE S2x ADD FILE (
name='S2x_mod1', filename='c:\data\S2x_mod1')
TO FILEGROUP S2x_mod;
I get as far as the last part of the above query and get the following error:
Could not process the operation. Always On Availability Groups replica manager is disabled on this instance of SQL Server. Enable Always On Availability Groups, by using the SQL Server Configuration Manager. Then, restart the SQL Server service, and retry the currently operation. For information about how to enable and disable Always On Availability Groups, see SQL Server Books Online.
When trying to enable the option via the SQL Server Configuration Manager, it says that turning on "Always On Availability Groups" is not possible with this version of SQL Express.
With the 2019 version I get past the above query and manage to create a memory-optimized table and native stored procedure:
-- Creating a memory-optimized table
CREATE TABLE dbo.State
(
CID NVARCHAR(50) NOT NULL PRIMARY KEY NONCLUSTERED HASH WITH (BUCKET_COUNT = 1000),
PNO INT NOT NULL,
IsStart BIT NOT NULL,
IsEnd BIT NOT NULL,
CMPID NVARCHAR(50) NOT NULL
)
WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA);
GO
CREATE PROCEDURE dbo.GetStateByCID
@CID NVARCHAR(50)
WITH NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS OWNER
AS
BEGIN ATOMIC WITH
(
TRANSACTION ISOLATION LEVEL = SNAPSHOT,
LANGUAGE = N'English'
)
SELECT CID, PNO, IsStart, IsEnd, CMPID
FROM dbo.State
WHERE CID = @CID;
END;
but when executing it:
EXEC @return_value = [dbo].[GetStateByCID]
@CID = N'1234'
I get the following error:
An error occurred while executing batch. Error message is: Internal connection fatal error. Error state: 15, Token : 0
I did not find a lot of help online on this; but it seemed to be an issue which was fixed in the 2017 version (see here). This does not make much sense to me, as I would have expected the fix to be included in the 2019 version by default. In any case, using In-Memory OLTP would only be possible for me, if it is compatible with both Express 2019 and 2022.
What am I missing here? Is In-Memory OLTP compatible with SQL express or not? Am I doing something wrong?