我正在使用 SQL Server 2012 Express LocalDB。如果实例没有活动,它们似乎会在10分钟后自动停止。是否有一种干净的方式让实例永远运行下去?
我正在使用 SQL Server 2012 Express LocalDB。如果实例没有活动,它们似乎会在10分钟后自动停止。是否有一种干净的方式让实例永远运行下去?
可以通过 T-SQL 中的 'user instance timeout'
选项对超时时间进行配置:
sp_configure 'show advanced options', 1;
RECONFIGURE;
GO
sp_configure 'user instance timeout', 5;
GO
65535
。设置后,我相信您需要重启实例。请不要尝试将其设置为0
,这只会使实例在启动后立即关闭,这将使将值重新设置为有用的值变得困难 :-)。以下是如何在命令行中执行Krzysztof Kozielczyk的答案。
启动localdb
实例。
C:\> sqllocaldb start v11.0
LocalDB instance "v11.0" started.
获取服务器路径,即实例管道名称。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
在该服务器上运行一个 SQL 命令。
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
sp_configure 'user instance timeout'
。 - Nelson