未能找到存储过程sp_

This article gives a comprehensive overview of custom stored procedure sp_whoisactive.

本文对自定义存储过程sp_whoisactive进行了全面概述。

介绍 (Introduction)

Usually, DBAs use sp_who, and sp_who2 system stored procedures to view the current sessions, users, and processes in a SQL instance. We can also identify blocking and active sessions from these procedures. We can use dynamic management views (DMVs) and dynamic management functions (DMFs) to get detailed internal useful information about SQL Server processes, waits, memory, and CPU.

通常,DBA使用sp_who和sp_who2系统存储过程来查看SQL实例中的当前会话,用户和进程。 我们还可以从这些过程中确定阻塞会话和活动会话。 我们可以使用动态管理视图(DMV)和动态管理功能(DMF)来获取有关SQL Server进程,等待,内存和CPU的详细内部有用信息。

谁 (Sp_who)

We use sp_who procedure to get user and background process information. It gives necessary information such as login, hostnames, command, blocking, and database against which it is running.

我们使用sp_who过程获取用户和后台进程信息。 它提供必要的信息,例如登录名,主机名,命令,阻止和与其运行的数据库。

Sp_who2 (Sp_who2)

It gives more information than the sp_who procedure. The DBA mainly uses this stored procedure for general information about the processes. It is an undocumented procedure but still useful. We get additional columns such as CPUTime, DiskIO, LastBatch, and ProgramName from this stored procedure.

它提供了比sp_who过程更多的信息。 DBA主要使用此存储过程获取有关过程的常规信息。 这是一个未记录的过程,但仍然有用。 我们从该存储过程中获得了其他列,例如CPUTime,DiskIO,LastBatch和ProgramName。

These procedures do not give much useful information such as wait information, execution plan, current running statements, duration. Now, let me introduce another useful stored procedure sp_WhoIsActive to get an instant view of SQL Server user processes. It is developed by Microsoft MVP Adam Machanic. We can use this stored procedure from SQL Server 2005 onwards. You can refer to the official documentation on whoisactive. It collects data from various DMV’s and shows information in a tabular format.

这些过程没有提供太多有用的信息,例如等待信息,执行计划,当前运行的语句,持续时间。 现在,让我介绍另一个有用的存储过程sp_WhoIsActive,以获取SQL Server用户进程的即时视图。 它由Microsoft MVP Adam Machanic开发 。 我们可以从SQL Server 2005开始使用此存储过程。 您可以参考whoisactive的官方文档。 它从各种DMV收集数据,并以表格格式显示信息。

It is a custom stored procedure. We can download the latest version from GitHub. The current version is 11.33. Open the URL and download the ZIP version of it.

这是一个自定义存储过程。 我们可以从GitHub下载最新版本。 当前版本是11.33。 打开URL并下载其ZIP版本。

Extract the ZIP file, and you can run a SQL Script who_is_active.sql

解压缩ZIP文件,然后可以运行SQL脚本who_is_active.sql

Open this script in SSMS and execute it. It creates a custom stored procedure sp_WhoIsActive.

在SSMS中打开此脚本并执行。 它创建一个自定义存储过程sp_WhoIsActive。

It is always a best practice to check documentation before using the procedure. We can execute this with @help = 1 argument to get the following information.

在使用该过程之前,最好先检查文档。 我们可以使用@help = 1参数执行此操作以获取以下信息。

  1. The first section shows the version, copyright, feedback email, License, and URL information 第一部分显示版本,版权,反馈电子邮件,许可证和URL信息
  2. In the second section, it shows available parameters, their description, and their default information 在第二部分中,它显示了可用的参数,它们的描述及其默认信息。
  3. The last section shows the columns data types, formatting option, and description:

    最后一部分显示了列的数据类型,格式选项和说明:

Let’s run sp_WhoIsActive without any parameter. Before executing this, open a new query window and execute the following query.

让我们运行不带任何参数的sp_WhoIsActive。 在执行此操作之前,请打开一个新的查询窗口并执行以下查询。

/****** Script for SelectTopNRows command from SSMS  ******/
SELECT TOP (1000) [EmployeeID],[FirstName],[CustomerId],[CustomerID1],[CompanyName],[OrderID],[ProductID],[ProductName],[OrderDate],[UnitPrice],[Quantity],[SubTotal]FROM [SQLShackDemo].[dbo].[SalesData]Go 1000

Let’s understand the useful output columns of sp_WhoIsActive stored procedure.

让我们了解sp_WhoIsActive存储过程的有用的输出列。

  • dd hh:mm:ss:mss: It shows the duration of the command. We can use this column to identify long-running transactions. For example, we can identify SQL Server sessions running from more than 1 hr dd hh:mm:ss:mss:显示命令的持续时间。 我们可以使用此列来标识长期运行的事务。 例如,我们可以识别运行超过1小时SQL Server会话

    • It shows query running time for an active request 它显示了活动请求的查询运行时间
    • In case of a sleeping session, it shows the time since the last completed batch 如果处于Hibernate状态,它将显示自上次完成批次以来的时间
  • session_id: It is the SP ID of the user session session_id:用户会话的SP ID
  • Sql_text: We can find out the SQL text for the running session. It is a hyperlink. We click on it and get the complete t-SQL Sql_text:我们可以找到正在运行的会话SQL文本。 这是一个超链接。 我们单击它并获得完整的t-SQL
  • Login name: It is the login that is connected to SQL Server and executing the SQL specified in the session
  • 登录名:这是连接到SQL Server并执行会话中指定SQL的登录名
  • Wait_info: It is a useful column to identify current wait for the SPID such as CXPACKET, ASYNC_NETWORK_IO along with wait time. Refer to the article for Wait_info:这是一个有用的列,用于标识当前等待SPID的时间(例如CXPACKET,ASYNC_NETWORK_IO)以及等待时间。 请参阅有关SQL Server wait types SQL Server等待类型的文章
  • Tempdb_allocations and tempdb_current: If a query is using the TempDB database, we get the information about tempdb allocations using this column. For example, if we use a table variable or temporary table, it gets created in the TempDB, and we can track information using these columns Tempdb_allocations和tempdb_current:如果查询使用的是TempDB数据库,则使用此列获取有关tempdb分配的信息。 例如,如果我们使用表变量或临时表,则会在TempDB中创建它,我们可以使用这些列来跟踪信息
  • CPU: We get the total CPU time consumed by the query from this CPU:我们从中获取查询所消耗的总CPU时间
  • Blocking_session_id: In the case of blocking, we can get the blocking session-id from this column
  • Blocking_session_id:阻止的情况下,我们可以从此列中获取阻止的会话ID
  • Reads and writes: It gives the number of reads and writes for the current query 读写:给出当前查询的读写次数
  • Open_tran_count: It shows the number of open transactions for the session Open_tran_count:显示会话的未完成交易数
  • Percent complete: We can check the percentage completion status of the few commands using the DMV sys.dm_exec_requests, such as backup and restore database commands. Sp_WhoIsActive uses this DMV information and displays it the output 完成百分比:我们可以使用DMV sys.dm_exec_requests检查一些命令的完成百分比状态,例如备份和还原数据库命令。 Sp_WhoIsActive使用此DMV信息并将其显示为输出
  • Program name: It gives the application name from where the user is connected, such as Microsoft SQL Server Management Studio – Query, Azure Data Studio, SQL Server Agent 程序名称:提供用户连接所在的应用程序名称,例如Microsoft SQL Server Management Studio –查询,Azure Data Studio,SQL Server代理

Let’s look at a few optional parameters and their usage with sp_WhoIsActive procedure.

让我们看一些可选参数及其在sp_WhoIsActive过程中的用法。

@find_block_leaders: (@find_block_leaders:)

We can set value for @find_block_leaders argument to 1 and sorts the results for blocked_session_count column to check lead blockers and blocked sessions.

我们可以将@find_block_leaders参数的值设置为1,然后对blocked_session_count列的结果进行排序,以检查潜在客户阻止程序和被阻止的会话。

EXEC sp_WhoIsActive@find_block_leaders = 1,@sort_order = '[blocked_session_count] DESC'

In the output, we see session-id 58 is the lead blocker, and it blocked 2 sessions that are listed below in the output table.

在输出中,我们看到session-id 58是线索阻止程序,它阻止了输出表中下面列出的2个会话。

@get_plans (@get_plans)

Suppose you are investigating a performance issue in SQL Server and you identified a problematic query. It is good if we can get an execution plan of it for looking at costly operators involved in query execution.

假设您正在调查SQL Server中的性能问题,并且发现了有问题的查询。 如果我们能得到它的执行计划以查看查询执行中涉及的昂贵运算符,那将是一个很好的选择。

We can specify the argument @get_plans=1, and it includes an additional column in the output with the XML execution plan.

我们可以指定参数@ get_plans = 1 ,并在输出中包含带有XML执行计划的附加列。

EXEC sp_WhoIsActive @get_plans = 1;

Click on the query plan, and you can see the query execution plan.

单击查询计划,您可以看到查询执行计划。

@get_locks (@get_locks)

We can use this argument to get an XML snippet to get detail information about locks held in a session of SQL Server. In the output, we get an additional column locks, as shown below. Click on the locks, and you get XML format locks information.

我们可以使用此参数获取XML代码段,以获取有关在SQL Server会话中持有的锁的详细信息。 在输出中,我们获得了附加的列锁,如下所示。 单击锁,您将获得XML格式锁信息。

@get_additional_info (@get_additional_info)

We can set several session parameters that might affect query performance as well. Sp_WhoIsActive gives you an argument @get_additional_info and shows information about those parameters.

我们可以设置几个可能也会影响查询性能的会话参数。 Sp_WhoIsActive为您提供一个参数@get_additional_info并显示有关这些参数的信息。

EXEC sp_WhoIsActive @get_additional_info = 1

Azure Data Studio中的Sp_WhoIsActive扩展 (Sp_WhoIsActive extension in Azure Data Studio)

Azure Data Studio is a new cross-platform client tool suitable for both developers and DBAs. Extensions play an important role in Azure Data Studio as they enhance functionalities of it. We can install the extensions from the market place and use it as per our requirement. You can explore a few useful Azure Data Studio extensions on SQLShack.

Azure Data Studio是适用于开发人员和DBA的新的跨平台客户端工具。 扩展在Azure Data Studio中起着重要作用,因为它们增强了功能。 我们可以从市场上安装扩展,并根据我们的要求使用它。 您可以在SQLShack上探索一些有用的Azure Data Studio扩展 。

It contains an extension for sp_whoisactive and gives output in graphical format. Currently, it is in the preview phase.

它包含sp_whoisactive的扩展,并以图形格式提供输出。 当前,它处于预览阶段。

Click on Install, and it enables this extension globally.

单击安装,它将在全局启用此扩展。

Now, connect to SQL instance in Azure Data Studio. Right-click on the database and select Manage. You get the following default page as output.

现在,连接到Azure Data Studio中SQL实例。 右键单击数据库,然后选择管理。 您将获得以下默认页面作为输出。

In the tasks, we can click on the respective block, and it automatically gives you a query with the required parameter.

在任务中,我们可以单击相应的块,它会自动为您提供带有所需参数的查询。

For example, if we click on WhoIsActive: Get plans, it gives the following query.

例如,如果我们单击WhoIsActive:获取计划 ,它将给出以下查询。

Similarly, for WhoIsActive: Find block leaders, we get the following query with required arguments.

类似地,对于WhoIsActive:查找块领导者 ,我们得到以下带有必需参数的查询。

结论 (Conclusion)

Sp_WhoIsActive is a useful custom stored procedure and gives important insights from the user sessions in SQL Server with information such as lead blocker, execution plan, wait stats, query text. I would recommend you installing this stored procedure and be familiar with it. You can also use it in Azure Data Studio using the extension, as shown in this article.

Sp_WhoIsActive是一个有用的自定义存储过程,可从SQL Server中的用户会话中获得重要见解,并提供潜在客户阻止程序,执行计划,等待状态,查询文本等信息。 我建议您安装此存储过程并熟悉它。 您也可以使用扩展功能在Azure Data Studio中使用它,如本文所示。

翻译自: https://www.sqlshack.com/an-overview-of-the-sp_whoisactive-stored-procedure/

未能找到存储过程sp_

未能找到存储过程sp__sp_WhoIsActive存储过程概述相关推荐

  1. 存储过程和函数——概述||创建存储过程||调用存储过程||查看存储过程||删除存储过程

    存储过程和函数概述 存储过程和函数是事先经过编译并存储在数据库中的一段 SQL 语句的集合, 调用存储过程和函数可以简化应用开发人员的很多工作,减少数据在数据库和应用服务器之间的传输,对于提高数据处理 ...

  2. 最全MySQL8.0实战教程 14 MySQL的存储过程 14.1 概述

    最全MySQL8.0实战教程 文章目录 最全MySQL8.0实战教程 14 MySQL的存储过程 14.1 概述 14.1.1 什么是存储过程 14.1.2 特性 [黑马程序员MySQL知识精讲+my ...

  3. ObjectDataSource未能找到带参数的非泛型方法的解决

    ObjectDataSource""未能找到带参数的非泛型方法"DelnewsClass": newsClassID, original_NewsClassid ...

  4. 错误913:未能找到ID为13的数据库。可能该数据库尚未激活,也可能正在转换过程中...

    SQL SERVER2000 强行重启后出现如下错误提示: 错误913:未能找到ID为13的数据库.可能该数据库尚未激活,也可能正在转换过程中. 参阅SQL SERVER2000联机帮助文件,提示如下 ...

  5. 60-420-020-使用-存储过程-使用存储过程和函数插入大数据量

    文章目录 1.概述 1.1 准备 1.2 创建函数 1.3 创建存储过程 1.4 执行 2.删除函数与存储过程 2.1.删除函数 2.2.删除存储过程 总结 1.概述 1.1 准备 创建tb_dept ...

  6. mysql 存储过程 compile_存储过程 | iMySQL | 老叶茶馆

    A.4. MySQL 5.0 FAQ - 存储过程 Questions 26.4.1: MySQL 5.0是否支持存储过程? Does MySQL 5.0 support stored procedu ...

  7. oracle 别名 存储过程_oracle 存储过程 别名

    阿里云如何打破Oracle迁移上云的壁垒 2018第九届中国数据库技术大会,阿里云数据库产品专家萧少聪带来以阿里云如何打破Oracle迁移上云的壁垒为题的演讲.Oracle是指"数据库管理系 ...

  8. [百万级]通用存储过程.分页存储过程

    /*  名称:spAll_ReturnRows  输入:  输出:  调用:   EXEC spAll_ReturnRows 'SELECT  * FROM 表名', 页号, 返回记录数, '主键', ...

  9. VS2017 Pro未能找到路径“……\bin\roslyn\csc.exe”的解决方案

    VS2017 Pro未能找到路径"--\bin\roslyn\csc.exe"的解决方案 参考文章: (1)VS2017 Pro未能找到路径"--\bin\roslyn\ ...

最新文章

  1. 英伟达联手Arm CPU打造AI超算,百万兆级性能,主攻气候变化和核武建模
  2. Python 技术篇-socket套接字实现两个窗口间消息传递实例演示,TCP实现
  3. 一个jsp页面中多个提交按钮提交不同的页面
  4. 若依前后端分离版本,Windows下使用Nginx代理的方式进行部署(全流程,图文教程)
  5. 成大事必备9种能力、9种手段、9种心态
  6. html显示高亮c++
  7. metasploitable2渗透测试
  8. 微信 小程序 常见错误
  9. 【转载】最全最详细Hadoop学习文章
  10. node中使用短信验证功能(阿里云为例)
  11. php 导出excel类,php 导出excel类
  12. 从零开始学前端:中括号代替点操作,获取对象,自定义标签属性 --- 今天你学习了吗?(JS:Day3)
  13. 【嵌入式】非操作系统下GPIO口控制器及LED灯编程
  14. 2017 ACM暑期多校联合训练 - Team 3 1008 HDU 6063 RXD and math (莫比乌斯函数)...
  15. java线程协作_java线程系列之三(线程协作)
  16. python制作gif动图_Python几行代码制作Gif动图
  17. 华为RH2288做raid方法
  18. 1条命令解决不能完成此操作,因为项目“Karabiner-Elements”已被锁定
  19. 一辉Oo的视觉算法学习笔记2
  20. ASP.NET程序员常用的85个工具

热门文章

  1. Unity中使用gRPC
  2. 不用更改注册表就可以更改桌面所在的位置
  3. [转载] 分布式系统trace实践
  4. AX向在线用户发送消息
  5. offsetParent
  6. JS:ES6-10 class类
  7. LeetCode(868)——二进制间距(JavaScript)
  8. ionic 1页面跳转登录页面后,返回按钮处理
  9. 最新电脑为什么用ghost无法安装系统?安装版正常,是何原因?
  10. 生活中有哪些越早明白越好的道理?