SQL SERVER – Attach an In-Memory Database with T-SQL

Earlier I wrote a blog post about SQL SERVER – Attach a Database with T-SQL. Right after reading this blog post, my client of Comprehensive Database Performance Health Check sent me an email asking if there is any other method when we have to attach an In-Memory Database with T-SQL. The question is very valid as SSMS graphical user interface does not support attaching an in-memory database. Let us learn how we can do that today.

SQL SERVER - Attach an In-Memory Database with T-SQL withtsql-1-800x230

Here is the script which works with In-Memory Database.

( FILENAME = N'D:\Data\AdventureWorks.mdf' ),
( FILENAME = N'E:\Log\AdventureWorks_log.ldf' ),
(FILENAME = N'G:\InMemoryFolder')

When you are moving the in-memory database, make sure that you remember the name of the file stream folder where the in-memory objects are stored and you can specify that after specifying data and log file as a filename in the script.

I have not found much help on the internet on this topic, hence this blog post. If there is any inaccuracy in the script or any other method to attach the in-memory database via T-SQL, please leave a comment and I will be happy to share the same blog readers with due credit to you.

I like to create small videos teaching valuable lessons about T-SQL, you can subscribe to my channel SQL in Sixty Seconds to learn new stuff about technology.

Reference: Pinal Dave (https://blog.sqlauthority.com)

Exit mobile version