How to prevent SQL Server LocalDB auto shutdown?

后端 未结 2 946
滥情空心
滥情空心 2020-12-02 13:31

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 r

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 14:14

    Here is how to do Krzysztof Kozielczyk's answer from the command line.

    Start the localdb instance.

    C:\> sqllocaldb start v11.0
    LocalDB instance "v11.0" started.
    

    Get the server path, which is the Instance pipe name.

    C:\> sqllocaldb info v11.0
    Name:               v11.0
    Version:            11.0.3000.0
    Shared name:        IIS_DB
    Owner:              DESKTOP-AAAT5QS\bigfo
    Auto-create:        Yes
    State:              Running
    Last start time:    2/17/2016 12:06:43 PM
    Instance pipe name: np:\\.\pipe\LOCALDB#SH9D87FB\tsql\query
    

    Run an SQL command on that server.

    C:\> sqlcmd -S np:\\.\pipe\LOCALDB#SH9D87FB\tsql\query
    
    1> sp_configure 'show advanced options', 1;
    2> GO
    
    Configuration option 'show advanced options' changed from 1 to 1. 
    Run the RECONFIGURE statement to install.
    
    1> RECONFIGURE;
    2> GO
    
    1> sp_configure 'user instance timeout', 5;
    2> GO
    
    Configuration option 'user instance timeout' changed from 5 to 5. 
    Run the RECONFIGURE statement to install.
    
    1> RECONFIGURE;
    2> GO
    
    > exit
    

提交回复
热议问题