Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent SQL Server LocalDB auto shutdown?

Tags:

I'm using SQL Server 2012 Express LocalDB. Instances seem to stop automatically after 10 minutes if there is no activity on them. Is there a clean way to keep an instance running forever?

like image 853
user1947865 Avatar asked Jan 04 '13 08:01

user1947865


People also ask

How do I stop LocalDB instance?

As the message says, the automatic MSSQLLocalDB instance is in use. In order to be deleted, first it should be stopped. Type the SqlLocalDB stop MSSQLLocaDB command in the Command Prompt window: LocalDB instance “MSSQLLocalDB” stopped.

What is SQL LocalDB?

Microsoft SQL Server Express LocalDB is a feature of SQL Server Express targeted to developers. It is available on SQL Server Express with Advanced Services. LocalDB installation copies a minimal set of files necessary to start the SQL Server Database Engine.


1 Answers

The timeout is configurable via T-SQL with 'user instance timeout' option:

sp_configure 'show advanced options', 1; RECONFIGURE; GO sp_configure 'user instance timeout', 5; GO 

The timeout is expressed in minutes and has a maximum value of 65535. I'm pretty sure you need to restart the instance after setting it. And don't try setting it to 0, it will just make the instance shut down immediately after starting, which will make it hard to set the value back to something useful :-).

Source: this BOL article containing other useful information on User Instances that are applicable to LocalDB instances as well.

Final Remark

If you need something that's always running and starts whenever a computer starts you might just consider using regular, service-based, instance of SQL Server Express.

like image 195
Krzysztof Kozielczyk Avatar answered Oct 09 '22 20:10

Krzysztof Kozielczyk