SQL Server Management Studio 2008 中的“经典”活动监视器?

SQL Server Management Studio 2008 中的“经典”活动监视器?

目前,我正在使用 SQL Server Management Studio 2005 来管理我的所有 SQL 服务器(2000、2005、2008)。我很乐意能够利用 SSMS 2008 中的所有酷炫新功能,唯一阻碍我的是新的基于 DMV 的活动监视器:

  • 我们仍有 40% 的 SQL 2000,它没有新监视器所需的 DMV
  • 我不像喜欢旧版本那样喜欢它:)

那么是否有人为 SSMS 2008 制作了模拟旧活动监视器的插件?如果没有,那么是否有一套精巧的脚本可以完成相同或更好的任务,并且可以在 2000-2008 之间工作(不仅仅是 sp_who2)?

答案1

检查内置的(但我认为没有文档记录?)存储过程sp_MSset_current_activitysp_MSget_current_activity。它们应该能为您提供所需的所有信息 - 只是不如活动监视器那么漂亮。

使用示例:

declare @id int
exec dbo.sp_MSset_current_activity @id output

exec dbo.sp_MSget_current_activity @id, @option = 1
exec dbo.sp_MSget_current_activity @id, @option = 2
exec dbo.sp_MSget_current_activity @id, @option = 3
exec dbo.sp_MSget_current_activity @id, @option = 4, @spid = 51 -- locks per spid
exec dbo.sp_MSget_current_activity @id, @option = 5, @obj = N'sysobjects'

获取过程中有注释,概述了不同的可用选项。

相关内容