SQL Server 2005 - 关闭休眠连接
我的开发服务器上似乎有一个应用程序,它有很多打开的连接(它们应该在那里,但使用了一些错误的数据层来打开它们,忘记关闭它们)。 我只是希望它们关闭,这样我就可以让其他应用程序在服务器上运行。 如何强制关闭所有连接?
I seem to have an app on my Dev server that has lots of open connections (they should be there, but some bad data layer was used to open them, that forgot to close them). I just want them closed so I can keep other apps running on the server. How can I force all the connections to close?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用以下脚本来终止来自特定主机/登录名的非活动会话。 您可以从计划的作业中使用它,当然您的首要任务应该是修复您的应用程序层。
Use the following script to kill inactive sessions from a specific host / login. You could use it from a scheduled job, of course your priority should be to fix your app tier.
除了手动终止连接之外,您还可以
Other than killing your connections manually, you can
使用 sysprocesses 中的last_batch 列来确定它是否真正处于活动状态。
SPID> 50(或者 >= 50?)以避免杀死系统 SPID。
将其与您想要的睡眠时间进行比较并杀死 spid。
你必须循环遍历。
Use the last_batch column from sysprocesses to work out if it's really active or not.
SPID > 50 (or is it >= 50?) to avoid killing system SPIDs.
Compare this to your desired sleep time and KILL spid.
You'll have to loop through.
首先运行它来查找有问题的数据库......
然后运行它来终止与所需数据库的连接
First run this to find the offending database.....
Then run this to kill the connections to the desired DB