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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With