Does SQL Sever support inmemory database?How do I perform an IF…THEN in an SQL SELECT?Add a column with a default value to an existing table in SQL ServerHow to return only the Date from a SQL Server DateTime datatypeHow to check if a column exists in a SQL Server table?How to concatenate text from multiple rows into a single text string in SQL server?Parameterize an SQL IN clauseLEFT JOIN vs. LEFT OUTER JOIN in SQL ServerInserting multiple rows in a single SQL query?How do I UPDATE from a SELECT in SQL Server?Get size of all tables in database
How can I raise concerns with a new DM about XP splitting?
Is a naturally all "male" species possible?
Can I use my Chinese passport to enter China after I acquired another citizenship?
Bob has never been a M before
Can a Gentile theist be saved?
Could solar power be utilized and substitute coal in the 19th century?
Superhero words!
Installing PowerShell on 32-bit Kali OS fails
Calculating the number of days between 2 dates in Excel
Why does this part of the Space Shuttle launch pad seem to be floating in air?
What was required to accept "troll"?
Visiting the UK as unmarried couple
My boss asked me to take a one-day class, then signs it up as a day off
Was the picture area of a CRT a parallelogram (instead of a true rectangle)?
Is there enough fresh water in the world to eradicate the drinking water crisis?
A workplace installs custom certificates on personal devices, can this be used to decrypt HTTPS traffic?
Can I rely on these GitHub repository files?
How will losing mobility of one hand affect my career as a programmer?
Indicating multiple different modes of speech (fantasy language or telepathy)
What (else) happened July 1st 1858 in London?
The most efficient algorithm to find all possible integer pairs which sum to a given integer
Teaching indefinite integrals that require special-casing
Simulating a probability of 1 of 2^N with less than N random bits
Simple recursive Sudoku solver
Does SQL Sever support inmemory database?
How do I perform an IF…THEN in an SQL SELECT?Add a column with a default value to an existing table in SQL ServerHow to return only the Date from a SQL Server DateTime datatypeHow to check if a column exists in a SQL Server table?How to concatenate text from multiple rows into a single text string in SQL server?Parameterize an SQL IN clauseLEFT JOIN vs. LEFT OUTER JOIN in SQL ServerInserting multiple rows in a single SQL query?How do I UPDATE from a SELECT in SQL Server?Get size of all tables in database
I have basically a testing scenario, where I
- Create database
- Fill it with some data
- Execute the business logic to be tested, which modifies the data. I don't own the business logic implementation, not the DB schema. I must test what is already there.
- Assert the data are changed as expected
- Delete the database
Does SQL Server support something like that in memory only, so that I can seed it up? Obviously I don't need persistence
sql-server integration-testing in-memory-database database-testing
|
show 14 more comments
I have basically a testing scenario, where I
- Create database
- Fill it with some data
- Execute the business logic to be tested, which modifies the data. I don't own the business logic implementation, not the DB schema. I must test what is already there.
- Assert the data are changed as expected
- Delete the database
Does SQL Server support something like that in memory only, so that I can seed it up? Obviously I don't need persistence
sql-server integration-testing in-memory-database database-testing
I don't know if SQL Server has an in-memory only version. But, you may look into using a cache layer on top of SQL Server. Or, for a pure in memory database, read about things like H2.
– Tim Biegeleisen
Mar 8 at 8:26
H2 does not help, because I don't own the existing implementation of the business logic
– Liero
Mar 8 at 8:28
That's the wrong question. SQL Server has in-memory tables since SQL Server 2014. All versions have temporary tables and table variables. All of those things would cover the bullet points. None of these are relevant for testing though (except perhaps for temporary tables)
– Panagiotis Kanavos
Mar 8 at 8:28
@PanagiotisKanavos I recant my earlier comment, but for integration testing, an actual SQL Server instance is precisely against what the OP should be running those tests. For unit testing, the database can be mocked.
– Tim Biegeleisen
Mar 8 at 8:31
1
@Liero another possibility would be to create the test database, detach it and use the files as a template. Each time you want a new test database, copy them to a new location followed by anATTACH DATABASE
. This will be faster than RESTORE because it won't have a recovery phase
– Panagiotis Kanavos
Mar 8 at 8:46
|
show 14 more comments
I have basically a testing scenario, where I
- Create database
- Fill it with some data
- Execute the business logic to be tested, which modifies the data. I don't own the business logic implementation, not the DB schema. I must test what is already there.
- Assert the data are changed as expected
- Delete the database
Does SQL Server support something like that in memory only, so that I can seed it up? Obviously I don't need persistence
sql-server integration-testing in-memory-database database-testing
I have basically a testing scenario, where I
- Create database
- Fill it with some data
- Execute the business logic to be tested, which modifies the data. I don't own the business logic implementation, not the DB schema. I must test what is already there.
- Assert the data are changed as expected
- Delete the database
Does SQL Server support something like that in memory only, so that I can seed it up? Obviously I don't need persistence
sql-server integration-testing in-memory-database database-testing
sql-server integration-testing in-memory-database database-testing
edited Mar 8 at 9:07
jarlh
29.8k52138
29.8k52138
asked Mar 8 at 8:21
LieroLiero
9,807745116
9,807745116
I don't know if SQL Server has an in-memory only version. But, you may look into using a cache layer on top of SQL Server. Or, for a pure in memory database, read about things like H2.
– Tim Biegeleisen
Mar 8 at 8:26
H2 does not help, because I don't own the existing implementation of the business logic
– Liero
Mar 8 at 8:28
That's the wrong question. SQL Server has in-memory tables since SQL Server 2014. All versions have temporary tables and table variables. All of those things would cover the bullet points. None of these are relevant for testing though (except perhaps for temporary tables)
– Panagiotis Kanavos
Mar 8 at 8:28
@PanagiotisKanavos I recant my earlier comment, but for integration testing, an actual SQL Server instance is precisely against what the OP should be running those tests. For unit testing, the database can be mocked.
– Tim Biegeleisen
Mar 8 at 8:31
1
@Liero another possibility would be to create the test database, detach it and use the files as a template. Each time you want a new test database, copy them to a new location followed by anATTACH DATABASE
. This will be faster than RESTORE because it won't have a recovery phase
– Panagiotis Kanavos
Mar 8 at 8:46
|
show 14 more comments
I don't know if SQL Server has an in-memory only version. But, you may look into using a cache layer on top of SQL Server. Or, for a pure in memory database, read about things like H2.
– Tim Biegeleisen
Mar 8 at 8:26
H2 does not help, because I don't own the existing implementation of the business logic
– Liero
Mar 8 at 8:28
That's the wrong question. SQL Server has in-memory tables since SQL Server 2014. All versions have temporary tables and table variables. All of those things would cover the bullet points. None of these are relevant for testing though (except perhaps for temporary tables)
– Panagiotis Kanavos
Mar 8 at 8:28
@PanagiotisKanavos I recant my earlier comment, but for integration testing, an actual SQL Server instance is precisely against what the OP should be running those tests. For unit testing, the database can be mocked.
– Tim Biegeleisen
Mar 8 at 8:31
1
@Liero another possibility would be to create the test database, detach it and use the files as a template. Each time you want a new test database, copy them to a new location followed by anATTACH DATABASE
. This will be faster than RESTORE because it won't have a recovery phase
– Panagiotis Kanavos
Mar 8 at 8:46
I don't know if SQL Server has an in-memory only version. But, you may look into using a cache layer on top of SQL Server. Or, for a pure in memory database, read about things like H2.
– Tim Biegeleisen
Mar 8 at 8:26
I don't know if SQL Server has an in-memory only version. But, you may look into using a cache layer on top of SQL Server. Or, for a pure in memory database, read about things like H2.
– Tim Biegeleisen
Mar 8 at 8:26
H2 does not help, because I don't own the existing implementation of the business logic
– Liero
Mar 8 at 8:28
H2 does not help, because I don't own the existing implementation of the business logic
– Liero
Mar 8 at 8:28
That's the wrong question. SQL Server has in-memory tables since SQL Server 2014. All versions have temporary tables and table variables. All of those things would cover the bullet points. None of these are relevant for testing though (except perhaps for temporary tables)
– Panagiotis Kanavos
Mar 8 at 8:28
That's the wrong question. SQL Server has in-memory tables since SQL Server 2014. All versions have temporary tables and table variables. All of those things would cover the bullet points. None of these are relevant for testing though (except perhaps for temporary tables)
– Panagiotis Kanavos
Mar 8 at 8:28
@PanagiotisKanavos I recant my earlier comment, but for integration testing, an actual SQL Server instance is precisely against what the OP should be running those tests. For unit testing, the database can be mocked.
– Tim Biegeleisen
Mar 8 at 8:31
@PanagiotisKanavos I recant my earlier comment, but for integration testing, an actual SQL Server instance is precisely against what the OP should be running those tests. For unit testing, the database can be mocked.
– Tim Biegeleisen
Mar 8 at 8:31
1
1
@Liero another possibility would be to create the test database, detach it and use the files as a template. Each time you want a new test database, copy them to a new location followed by an
ATTACH DATABASE
. This will be faster than RESTORE because it won't have a recovery phase– Panagiotis Kanavos
Mar 8 at 8:46
@Liero another possibility would be to create the test database, detach it and use the files as a template. Each time you want a new test database, copy them to a new location followed by an
ATTACH DATABASE
. This will be faster than RESTORE because it won't have a recovery phase– Panagiotis Kanavos
Mar 8 at 8:46
|
show 14 more comments
1 Answer
1
active
oldest
votes
SQL Server has in-memory OLTP. This feature is quite close to what you are looking into. Starting SQL Server 2016 SP1 it is possible in all editions, including sql express.
Obviously I don't need persistence
The option DURABILITY=SCHEMA_ONLY
preserves only the metadata. Such a scenario can be optimal for staging tables because it results in a lock/latch/log free way of data load. Obviously, the table will not survive instance/service restart.
CREATE DATABASE [Test]
GO
-- Memory Optimized FG
ALTER DATABASE [Test] ADD FILEGROUP [MemoryOptimizedFG] CONTAINS MEMORY_OPTIMIZED_DATA
ALTER DATABASE [Test] ADD FILE (name='Test1', filename='D:SQLDataTestInMemory') TO FILEGROUP [MemoryOptimizedFG]
GO
CREATE TABLE dbo.[TestTable] (
ID int NOT NULL IDENTITY (1, 1) PRIMARY KEY NONCLUSTERED,
ColumnID int NOT NULL,
Description varchar(100) NOT NULL,
dateAndTime datetime NOT NULL
) WITH (MEMORY_OPTIMIZED=ON, DURABILITY=SCHEMA_ONLY)
GO
References:
- https://www.red-gate.com/simple-talk/sql/database-administration/in-memory-oltp-understanding-memory-optimized-tables/
- https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/in-memory-oltp-in-memory-optimization?view=sql-server-2017
This is almost what I'm looking for, but It doesn't help me with cleaning data after the test is finished, so I need to delete and recreate the DB anyway
– Liero
Mar 8 at 8:44
@Liero, for deletion and recreation you have steps 1 and 5 in your original testing scenario ;)
– Alexander Volok
Mar 8 at 8:47
1
@Liero what's the problem with that? What are you trying to avoid? DROP & CREATE don't take that long. Why would you need a transient database for this?
– Panagiotis Kanavos
Mar 8 at 8:48
Perhaps, you will want to keep an empty database, but delete/recreate in-memory objects in it
– Alexander Volok
Mar 8 at 8:48
@PanagiotisKanavos: Not really a problem, but if there was real inmemory db, it would make it much simpler and faster (there is a lot of tests) Since there isn't I will go with these approach probably. However, the DB scripts are given and I don't want to modify them. Let me check if I can ALTER TABLE WITH MEMORY_OPTIMIZED=ON
– Liero
Mar 8 at 8:59
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55059223%2fdoes-sql-sever-support-inmemory-database%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
SQL Server has in-memory OLTP. This feature is quite close to what you are looking into. Starting SQL Server 2016 SP1 it is possible in all editions, including sql express.
Obviously I don't need persistence
The option DURABILITY=SCHEMA_ONLY
preserves only the metadata. Such a scenario can be optimal for staging tables because it results in a lock/latch/log free way of data load. Obviously, the table will not survive instance/service restart.
CREATE DATABASE [Test]
GO
-- Memory Optimized FG
ALTER DATABASE [Test] ADD FILEGROUP [MemoryOptimizedFG] CONTAINS MEMORY_OPTIMIZED_DATA
ALTER DATABASE [Test] ADD FILE (name='Test1', filename='D:SQLDataTestInMemory') TO FILEGROUP [MemoryOptimizedFG]
GO
CREATE TABLE dbo.[TestTable] (
ID int NOT NULL IDENTITY (1, 1) PRIMARY KEY NONCLUSTERED,
ColumnID int NOT NULL,
Description varchar(100) NOT NULL,
dateAndTime datetime NOT NULL
) WITH (MEMORY_OPTIMIZED=ON, DURABILITY=SCHEMA_ONLY)
GO
References:
- https://www.red-gate.com/simple-talk/sql/database-administration/in-memory-oltp-understanding-memory-optimized-tables/
- https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/in-memory-oltp-in-memory-optimization?view=sql-server-2017
This is almost what I'm looking for, but It doesn't help me with cleaning data after the test is finished, so I need to delete and recreate the DB anyway
– Liero
Mar 8 at 8:44
@Liero, for deletion and recreation you have steps 1 and 5 in your original testing scenario ;)
– Alexander Volok
Mar 8 at 8:47
1
@Liero what's the problem with that? What are you trying to avoid? DROP & CREATE don't take that long. Why would you need a transient database for this?
– Panagiotis Kanavos
Mar 8 at 8:48
Perhaps, you will want to keep an empty database, but delete/recreate in-memory objects in it
– Alexander Volok
Mar 8 at 8:48
@PanagiotisKanavos: Not really a problem, but if there was real inmemory db, it would make it much simpler and faster (there is a lot of tests) Since there isn't I will go with these approach probably. However, the DB scripts are given and I don't want to modify them. Let me check if I can ALTER TABLE WITH MEMORY_OPTIMIZED=ON
– Liero
Mar 8 at 8:59
add a comment |
SQL Server has in-memory OLTP. This feature is quite close to what you are looking into. Starting SQL Server 2016 SP1 it is possible in all editions, including sql express.
Obviously I don't need persistence
The option DURABILITY=SCHEMA_ONLY
preserves only the metadata. Such a scenario can be optimal for staging tables because it results in a lock/latch/log free way of data load. Obviously, the table will not survive instance/service restart.
CREATE DATABASE [Test]
GO
-- Memory Optimized FG
ALTER DATABASE [Test] ADD FILEGROUP [MemoryOptimizedFG] CONTAINS MEMORY_OPTIMIZED_DATA
ALTER DATABASE [Test] ADD FILE (name='Test1', filename='D:SQLDataTestInMemory') TO FILEGROUP [MemoryOptimizedFG]
GO
CREATE TABLE dbo.[TestTable] (
ID int NOT NULL IDENTITY (1, 1) PRIMARY KEY NONCLUSTERED,
ColumnID int NOT NULL,
Description varchar(100) NOT NULL,
dateAndTime datetime NOT NULL
) WITH (MEMORY_OPTIMIZED=ON, DURABILITY=SCHEMA_ONLY)
GO
References:
- https://www.red-gate.com/simple-talk/sql/database-administration/in-memory-oltp-understanding-memory-optimized-tables/
- https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/in-memory-oltp-in-memory-optimization?view=sql-server-2017
This is almost what I'm looking for, but It doesn't help me with cleaning data after the test is finished, so I need to delete and recreate the DB anyway
– Liero
Mar 8 at 8:44
@Liero, for deletion and recreation you have steps 1 and 5 in your original testing scenario ;)
– Alexander Volok
Mar 8 at 8:47
1
@Liero what's the problem with that? What are you trying to avoid? DROP & CREATE don't take that long. Why would you need a transient database for this?
– Panagiotis Kanavos
Mar 8 at 8:48
Perhaps, you will want to keep an empty database, but delete/recreate in-memory objects in it
– Alexander Volok
Mar 8 at 8:48
@PanagiotisKanavos: Not really a problem, but if there was real inmemory db, it would make it much simpler and faster (there is a lot of tests) Since there isn't I will go with these approach probably. However, the DB scripts are given and I don't want to modify them. Let me check if I can ALTER TABLE WITH MEMORY_OPTIMIZED=ON
– Liero
Mar 8 at 8:59
add a comment |
SQL Server has in-memory OLTP. This feature is quite close to what you are looking into. Starting SQL Server 2016 SP1 it is possible in all editions, including sql express.
Obviously I don't need persistence
The option DURABILITY=SCHEMA_ONLY
preserves only the metadata. Such a scenario can be optimal for staging tables because it results in a lock/latch/log free way of data load. Obviously, the table will not survive instance/service restart.
CREATE DATABASE [Test]
GO
-- Memory Optimized FG
ALTER DATABASE [Test] ADD FILEGROUP [MemoryOptimizedFG] CONTAINS MEMORY_OPTIMIZED_DATA
ALTER DATABASE [Test] ADD FILE (name='Test1', filename='D:SQLDataTestInMemory') TO FILEGROUP [MemoryOptimizedFG]
GO
CREATE TABLE dbo.[TestTable] (
ID int NOT NULL IDENTITY (1, 1) PRIMARY KEY NONCLUSTERED,
ColumnID int NOT NULL,
Description varchar(100) NOT NULL,
dateAndTime datetime NOT NULL
) WITH (MEMORY_OPTIMIZED=ON, DURABILITY=SCHEMA_ONLY)
GO
References:
- https://www.red-gate.com/simple-talk/sql/database-administration/in-memory-oltp-understanding-memory-optimized-tables/
- https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/in-memory-oltp-in-memory-optimization?view=sql-server-2017
SQL Server has in-memory OLTP. This feature is quite close to what you are looking into. Starting SQL Server 2016 SP1 it is possible in all editions, including sql express.
Obviously I don't need persistence
The option DURABILITY=SCHEMA_ONLY
preserves only the metadata. Such a scenario can be optimal for staging tables because it results in a lock/latch/log free way of data load. Obviously, the table will not survive instance/service restart.
CREATE DATABASE [Test]
GO
-- Memory Optimized FG
ALTER DATABASE [Test] ADD FILEGROUP [MemoryOptimizedFG] CONTAINS MEMORY_OPTIMIZED_DATA
ALTER DATABASE [Test] ADD FILE (name='Test1', filename='D:SQLDataTestInMemory') TO FILEGROUP [MemoryOptimizedFG]
GO
CREATE TABLE dbo.[TestTable] (
ID int NOT NULL IDENTITY (1, 1) PRIMARY KEY NONCLUSTERED,
ColumnID int NOT NULL,
Description varchar(100) NOT NULL,
dateAndTime datetime NOT NULL
) WITH (MEMORY_OPTIMIZED=ON, DURABILITY=SCHEMA_ONLY)
GO
References:
- https://www.red-gate.com/simple-talk/sql/database-administration/in-memory-oltp-understanding-memory-optimized-tables/
- https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/in-memory-oltp-in-memory-optimization?view=sql-server-2017
answered Mar 8 at 8:40
Alexander VolokAlexander Volok
3,492925
3,492925
This is almost what I'm looking for, but It doesn't help me with cleaning data after the test is finished, so I need to delete and recreate the DB anyway
– Liero
Mar 8 at 8:44
@Liero, for deletion and recreation you have steps 1 and 5 in your original testing scenario ;)
– Alexander Volok
Mar 8 at 8:47
1
@Liero what's the problem with that? What are you trying to avoid? DROP & CREATE don't take that long. Why would you need a transient database for this?
– Panagiotis Kanavos
Mar 8 at 8:48
Perhaps, you will want to keep an empty database, but delete/recreate in-memory objects in it
– Alexander Volok
Mar 8 at 8:48
@PanagiotisKanavos: Not really a problem, but if there was real inmemory db, it would make it much simpler and faster (there is a lot of tests) Since there isn't I will go with these approach probably. However, the DB scripts are given and I don't want to modify them. Let me check if I can ALTER TABLE WITH MEMORY_OPTIMIZED=ON
– Liero
Mar 8 at 8:59
add a comment |
This is almost what I'm looking for, but It doesn't help me with cleaning data after the test is finished, so I need to delete and recreate the DB anyway
– Liero
Mar 8 at 8:44
@Liero, for deletion and recreation you have steps 1 and 5 in your original testing scenario ;)
– Alexander Volok
Mar 8 at 8:47
1
@Liero what's the problem with that? What are you trying to avoid? DROP & CREATE don't take that long. Why would you need a transient database for this?
– Panagiotis Kanavos
Mar 8 at 8:48
Perhaps, you will want to keep an empty database, but delete/recreate in-memory objects in it
– Alexander Volok
Mar 8 at 8:48
@PanagiotisKanavos: Not really a problem, but if there was real inmemory db, it would make it much simpler and faster (there is a lot of tests) Since there isn't I will go with these approach probably. However, the DB scripts are given and I don't want to modify them. Let me check if I can ALTER TABLE WITH MEMORY_OPTIMIZED=ON
– Liero
Mar 8 at 8:59
This is almost what I'm looking for, but It doesn't help me with cleaning data after the test is finished, so I need to delete and recreate the DB anyway
– Liero
Mar 8 at 8:44
This is almost what I'm looking for, but It doesn't help me with cleaning data after the test is finished, so I need to delete and recreate the DB anyway
– Liero
Mar 8 at 8:44
@Liero, for deletion and recreation you have steps 1 and 5 in your original testing scenario ;)
– Alexander Volok
Mar 8 at 8:47
@Liero, for deletion and recreation you have steps 1 and 5 in your original testing scenario ;)
– Alexander Volok
Mar 8 at 8:47
1
1
@Liero what's the problem with that? What are you trying to avoid? DROP & CREATE don't take that long. Why would you need a transient database for this?
– Panagiotis Kanavos
Mar 8 at 8:48
@Liero what's the problem with that? What are you trying to avoid? DROP & CREATE don't take that long. Why would you need a transient database for this?
– Panagiotis Kanavos
Mar 8 at 8:48
Perhaps, you will want to keep an empty database, but delete/recreate in-memory objects in it
– Alexander Volok
Mar 8 at 8:48
Perhaps, you will want to keep an empty database, but delete/recreate in-memory objects in it
– Alexander Volok
Mar 8 at 8:48
@PanagiotisKanavos: Not really a problem, but if there was real inmemory db, it would make it much simpler and faster (there is a lot of tests) Since there isn't I will go with these approach probably. However, the DB scripts are given and I don't want to modify them. Let me check if I can ALTER TABLE WITH MEMORY_OPTIMIZED=ON
– Liero
Mar 8 at 8:59
@PanagiotisKanavos: Not really a problem, but if there was real inmemory db, it would make it much simpler and faster (there is a lot of tests) Since there isn't I will go with these approach probably. However, the DB scripts are given and I don't want to modify them. Let me check if I can ALTER TABLE WITH MEMORY_OPTIMIZED=ON
– Liero
Mar 8 at 8:59
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55059223%2fdoes-sql-sever-support-inmemory-database%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I don't know if SQL Server has an in-memory only version. But, you may look into using a cache layer on top of SQL Server. Or, for a pure in memory database, read about things like H2.
– Tim Biegeleisen
Mar 8 at 8:26
H2 does not help, because I don't own the existing implementation of the business logic
– Liero
Mar 8 at 8:28
That's the wrong question. SQL Server has in-memory tables since SQL Server 2014. All versions have temporary tables and table variables. All of those things would cover the bullet points. None of these are relevant for testing though (except perhaps for temporary tables)
– Panagiotis Kanavos
Mar 8 at 8:28
@PanagiotisKanavos I recant my earlier comment, but for integration testing, an actual SQL Server instance is precisely against what the OP should be running those tests. For unit testing, the database can be mocked.
– Tim Biegeleisen
Mar 8 at 8:31
1
@Liero another possibility would be to create the test database, detach it and use the files as a template. Each time you want a new test database, copy them to a new location followed by an
ATTACH DATABASE
. This will be faster than RESTORE because it won't have a recovery phase– Panagiotis Kanavos
Mar 8 at 8:46