如何知道SQL Server 2005中正在运行的存储过程

时间:2022-06-29 07:17:45

How can I know which stored procedure is running in SQL Server 2005. And also how to print that SP in the query?

如何知道SQL Server 2005中正在运行哪个存储过程。以及如何在查询中打印该SP?

4 个解决方案

#1


3  

SQL Profiler is usually a good start to log activity on a SQL Server instance

SQL事件探查器通常是在SQL Server实例上记录活动的良好开端

#2


1  

You can use SQL Profiler and Activity Manager

您可以使用SQL事件探查器和活动管理器

you can use

您可以使用

sp_helptext [sp_name]

to watch SP contents

观看SP内容

#3


0  

You can use the Activity Monitor in SQL Server Management Studio. It's located in the Management node. Once you have the Activity Monitor open have a look at the Command column to see what command is being executed. SQL Profiler is another option but it takes a bit more work to setup.

您可以在SQL Server Management Studio中使用活动监视器。它位于“管理”节点中。打开活动监视器后,请查看“命令”列以查看正在执行的命令。 SQL事件探查器是另一种选择,但它需要更多的工作来设置。

There's also an article here on how to monitor SPs.

这里还有一篇关于如何监控SP的文章。

#4


0  

In SQL Server 2005 and 2008, if you are trying to troubleshoot performance or behavior in a production system, you should be using the dynamic management views. Sys.dm_exec_requests will show you active transactions including useful information such as when it started, what the last lock was, if it's blocked, the blocking process, etc. You can also use sys.dm_exec_query_stats to see aggregated statistics of queries that are have been running and are still in cache. This will show interesting data like average run time, min/max run time, min/max/avg cpu, etc.

在SQL Server 2005和2008中,如果您尝试对生产系统中的性能或行为进行故障排除,则应使用动态管理视图。 Sys.dm_exec_requests将向您显示活动事务,包括有用的信息,例如何时启动,最后一次锁定,是否被阻止,阻塞过程等。您还可以使用sys.dm_exec_query_stats查看已经查询的汇总统计信息。正在运行并仍在缓存中。这将显示有趣的数据,如平均运行时间,最小/最大运行时间,最小/最大/平均CPU等。

Both these can then be used to link to other dmv's to retrieve execution plans, queries, and all kinds of other interesting information, on the fly, for cheap. It's much better than trying to maintain a set of trace events in most cases.

这些都可以用于链接到其他dmv,以便廉价地即时检索执行计划,查询和各种其他有趣的信息。在大多数情况下,它比尝试维护一组跟踪事件要好得多。

#1


3  

SQL Profiler is usually a good start to log activity on a SQL Server instance

SQL事件探查器通常是在SQL Server实例上记录活动的良好开端

#2


1  

You can use SQL Profiler and Activity Manager

您可以使用SQL事件探查器和活动管理器

you can use

您可以使用

sp_helptext [sp_name]

to watch SP contents

观看SP内容

#3


0  

You can use the Activity Monitor in SQL Server Management Studio. It's located in the Management node. Once you have the Activity Monitor open have a look at the Command column to see what command is being executed. SQL Profiler is another option but it takes a bit more work to setup.

您可以在SQL Server Management Studio中使用活动监视器。它位于“管理”节点中。打开活动监视器后,请查看“命令”列以查看正在执行的命令。 SQL事件探查器是另一种选择,但它需要更多的工作来设置。

There's also an article here on how to monitor SPs.

这里还有一篇关于如何监控SP的文章。

#4


0  

In SQL Server 2005 and 2008, if you are trying to troubleshoot performance or behavior in a production system, you should be using the dynamic management views. Sys.dm_exec_requests will show you active transactions including useful information such as when it started, what the last lock was, if it's blocked, the blocking process, etc. You can also use sys.dm_exec_query_stats to see aggregated statistics of queries that are have been running and are still in cache. This will show interesting data like average run time, min/max run time, min/max/avg cpu, etc.

在SQL Server 2005和2008中,如果您尝试对生产系统中的性能或行为进行故障排除,则应使用动态管理视图。 Sys.dm_exec_requests将向您显示活动事务,包括有用的信息,例如何时启动,最后一次锁定,是否被阻止,阻塞过程等。您还可以使用sys.dm_exec_query_stats查看已经查询的汇总统计信息。正在运行并仍在缓存中。这将显示有趣的数据,如平均运行时间,最小/最大运行时间,最小/最大/平均CPU等。

Both these can then be used to link to other dmv's to retrieve execution plans, queries, and all kinds of other interesting information, on the fly, for cheap. It's much better than trying to maintain a set of trace events in most cases.

这些都可以用于链接到其他dmv,以便廉价地即时检索执行计划,查询和各种其他有趣的信息。在大多数情况下,它比尝试维护一组跟踪事件要好得多。