惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 【当耐特】
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Y
Y Combinator Blog
D
DataBreaches.Net
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
I
InfoQ
L
LangChain Blog
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
C
Cybersecurity and Infrastructure Security Agency CISA
Know Your Adversary
Know Your Adversary
MongoDB | Blog
MongoDB | Blog
T
Tor Project blog
The Register - Security
The Register - Security
H
Help Net Security
Cisco Talos Blog
Cisco Talos Blog
P
Privacy & Cybersecurity Law Blog
NISL@THU
NISL@THU
P
Palo Alto Networks Blog
B
Blog RSS Feed
Latest news
Latest news
T
Threat Research - Cisco Blogs
The Hacker News
The Hacker News
C
Cisco Blogs
P
Privacy International News Feed
T
The Exploit Database - CXSecurity.com
V
Vulnerabilities – Threatpost
S
Schneier on Security
P
Proofpoint News Feed
Schneier on Security
Schneier on Security
www.infosecurity-magazine.com
www.infosecurity-magazine.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
AI
AI
Google Online Security Blog
Google Online Security Blog
H
Hacker News: Front Page
N
News and Events Feed by Topic
W
WeLiveSecurity

博客园 - 花光月影

【转】如何通过mdf文件还原数据库的两种方法 PowerDesign的使用技巧 [转]程序设计中的感悟 几个开源的PORTAL sql2000中修改表的所有者的存储过程 [转]如何让你的SQL运行快起来,希望有所帮助 影响SQLSERVER的性能的一些指标 久不见矣 程序中无法获得Request.ServerVariables("HTTP_REFERER")的值,寻求解决方法~~~~ 农历年底大家都很忙吗? 数据库的安全策略 SQL 事件探查器术语 SQL2000滴系统存储过程--sp_changeobjectowner(更改当前数据库中对象的所有者) SQL学习笔记----SQL2000中的角色及功能 .net中,如何获得活动目录(AD)上的密码失效时间? SQL数据库的事务日志意外增大或充满的处理方法 Sql Server数据库的备份和恢复措施 ASP调用.net的webservices的实现方法 ASP调用WebServices的方法?
[转贴]SQL Server用户连接的管理
花光月影 · 2007-07-20 · via 博客园 - 花光月影

同时用户连接的最大数

@@MAX_CONNECTIONS

返回 Microsoft® SQL Server™ 上允许的同时用户连接的最大数。
语法

@@MAX_CONNECTIONS

若要将 SQL Server 重新配置为更少的连接,应使用 sp_configure。

示例

SELECT @@MAX_CONNECTIONS /32767

在SQL Server里查看当前连接的在线用户数:

use master

select loginame,count(0) from sysprocesses
group by loginame
order by count(0) desc

select nt_username,count(0) from sysprocesses
group by nt_username
order by count(0) desc

如果某个SQL Server用户名test连接比较多,查看它来自的主机名:

select hostname,count(0) from sysprocesses where loginame='test'
group by hostname
order by count(0) desc

如果某个SQL Server用户名test连接比较多,查看它最后一次操作的时间范围分组:

select convert(varchar,last_batch,111),count(0) from sysprocesses where loginame='test'
group by convert(varchar,last_batch,111)
order by count(0) desc

如果从主机(www)来的连接比较多,可以查看它的进程详细情况

select * from  sysprocesses where hostname='www'

如果www机器主要提供网页服务,可能是asp程序处理连接时出了问题, 生成杀这些进程的SQL语句:

select 'kill '+convert(varchar,spid) from sysprocesses where hostname='www'

如果这样的问题频繁出现,可以写一个存储过程sp_KillIdleSpids.sql,

写一个作业, 执行它, 来自动杀掉从主机(www)来但已经一天没有响应的用户连接.