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

推荐订阅源

P
Privacy & Cybersecurity Law Blog
Engineering at Meta
Engineering at Meta
Forbes - Security
Forbes - Security
MongoDB | Blog
MongoDB | Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
A
About on SuperTechFans
量子位
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
雷峰网
雷峰网
腾讯CDC
P
Proofpoint News Feed
S
Schneier on Security
S
Secure Thoughts
V
Visual Studio Blog
Help Net Security
Help Net Security
The Hacker News
The Hacker News
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Privacy International News Feed
SecWiki News
SecWiki News
S
SegmentFault 最新的问题
T
Threatpost
小众软件
小众软件
MyScale Blog
MyScale Blog
F
Fortinet All Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
T
Tailwind CSS Blog
I
Intezer
C
CERT Recently Published Vulnerability Notes
U
Unit 42
V
V2EX
Cyberwarzone
Cyberwarzone
Recorded Future
Recorded Future
O
OpenAI News
Project Zero
Project Zero
有赞技术团队
有赞技术团队
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
Know Your Adversary
Know Your Adversary
C
Cybersecurity and Infrastructure Security Agency CISA
Scott Helme
Scott Helme
V2EX - 技术
V2EX - 技术
博客园 - 叶小钗
S
Securelist
A
Arctic Wolf
The Cloudflare Blog
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
博客园 - Franky

博客园 - 华博

SAP-续1 SAP專欄 也玩玩QQ的WEB(http://user.qzone.qq.com/7355541) 升職感言 - 华博 - 博客园 深深地記憶2007-07-09 重在參預:我眼中的東莞 勞動節到了,你准備好了嗎 四月一號去哪裡玩 新年來,又瘦下來了 Workflow培訓 方言武汉 最近相片,露個臉---SERVER 房間 RFID時代來臨了 一切源于基本 关于设计器类程序的模型,先抄下來,慢慢消化 System.ComponentModel.Component入门 c#中的回車jsp - 华博 - 博客园 Cursor spused
避免死锁
华博 · 2006-03-21 · via 博客园 - 华博

因为打开的事务可能会死锁资源,引发性能的问题,所以了解在一个专用数据库中哪些事务是打开的是很有帮助的。被死锁的资源可能堵塞其他数据库的用户。

为了找出这些已打开的事务就要查询master数据库中的sysprocesses表。sysprocesses表有一个open_tran的列,它表示已有命令是否是一个打开的事务。如果值大于0表示它是一个已经打开的事务。sysprocesses表还有一个spid的列,表示正在访问SQL Server的系统进程的id。你可以使用spid列作为DBCC INPUTBUFFER()系统函数的参数。只有SQL Server的sysadmins帐号才可以执行这个函数。这个函数的输出首先是spid对应的255字符的命令。你可以由此确定哪个命令是影响数据库性能的罪魁祸首,然后根据spid发出一个KILL命令。

下面是打印已打开事务的命令的脚本。它用到了表变量,因此只能在SQL Server 2000上用。

SET NOCOUNT ON
DECLARE @Commands
      TABLE
      ( ctr INT IDENTITY NOT NULL,
      command VARCHAR(2000) NOT NULL)

INSERT @Commands (command)
SELECT 'DBCC INPUTBUFFER (' + CONVERT( VARCHAR(10), spid) + ')'
FROM master..sysprocesses
WHERE open_tran > 0

DECLARE @ctr INT, @command VARCHAR(2000)
SET @ctr = 1

WHILE @ctr < (SELECT COUNT(*) + 1 FROM @Commands)
BEGIN
      SELECT @command = command FROM @Commands WHERE ctr = @ctr
      PRINT '-- ' + @command
      EXECUTE (@command)
      SELECT @ctr = @ctr + 1
END