In Memory Database

In-memory database technology is no longer just the latest buzz, in memory engines are spreading fast and will be highly disruptive to traditional on disk databases. supports two different manners to use in memory database one using @memory keyword to create internal in memory database and second it allows you to provide an external memory stream object to write, giving application complete control on it's data, the In-memory operations are orders of magnitude faster than disk operations.

It can be used for real time analytics, traditional OLTP , caching and complex data processing, there is no limit on the size of in memory database, it will keep on growing as long as operating system allow allocating more memory. Your application can have Multiple in memory databases and create large joins among them, including ability to convert on disk database to in memory database or just one object such as table.

Library support in memory database on all supported platforms, a lightweight non-persistent in-memory relational database engine that is purely written in .Net even works on mobile devices to do some in memory processing of data.

SQL Database engine makes in memory database easy to work with and easy to maintain.

using (SqlDatabaseConnection cnn = new SqlDatabaseConnection("uri=@memory"))
 cnn.Open(); //Created  
} // .net will call dispose
// Lost as using will dispose the connection.

The above code is for creating primary / main database in side the main memory.

Attaching In Memory Database not only support independent in memory database but also allow attaching in memory database to on disk database in the same connection providing extreme speed for any processing which require real time fast data. In-memory database can be written to disk with simple backup command.

ATTACH DATABASE '@memory' AS 'SchemaName' ;
Once you are done working with in memory database it can be detached to reduce memory consumption.
The primary database when created in memory is lost as soon as connection object is closed disposed or goes out of scope. The databases created using ATTACH are lost when detached or when connection is closed, disposed or goes out of scope similar to primary database. Primary database cannot be detached.