SET STATISTICS PROFILE (Transact-SQL)SET STATISTICS PROFILE (Transact-SQL)

适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 是Azure SQL 数据库Azure SQL DatabaseYesAzure SQL 数据库Azure SQL Database适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 是Azure SQL 数据库Azure SQL DatabaseYesAzure SQL 数据库Azure SQL Database

显示语句的配置文件信息。Displays the profile information for a statement. STATISTICS PROFILE 对即席查询、视图和存储过程有效。STATISTICS PROFILE works for ad hoc queries, views, and stored procedures.

主题链接图标 Transact-SQL 语法约定Topic link icon Transact-SQL Syntax Conventions

语法Syntax

  
SET STATISTICS PROFILE { ON | OFF }  

备注

若要查看 SQL Server 2014 及更早版本的 Transact-SQL 语法,请参阅早期版本文档To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation.

备注Remarks

STATISTICS PROFILE 为 ON 时,执行的各个查询都返回其常规结果集,后面跟一个附加结果集,显示查询执行的配置文件。When STATISTICS PROFILE is ON, each executed query returns its regular result set, followed by an additional result set that shows a profile of the query execution.

附加结果集包含查询的 SHOWPLAN_ALL 列以及下面的附加列。The additional result set contains the SHOWPLAN_ALL columns for the query and these additional columns.

列名称Column name 描述Description
Rows 各运算符生成的实际行数Actual number of rows produced by each operator
ExecutesExecutes 运算符执行的次数Number of times the operator has been executed

权限Permissions

若要使用 SET STATISTICS PROFILE 并查看输出,用户必须拥有下列权限:To use SET STATISTICS PROFILE and view the output, users must have the following permissions:

  • 执行 Transact-SQLTransact-SQL 语句的相应权限。Appropriate permissions to execute the Transact-SQLTransact-SQL statements.

  • 对包含 Transact-SQLTransact-SQL 语句引用的对象的所有数据库有 SHOWPLAN 权限。SHOWPLAN permission on all databases containing objects that are referenced by the Transact-SQLTransact-SQL statements.

对于不生成 STATISTICS PROFILE 结果集的 Transact-SQLTransact-SQL 语句,只需具有 Transact-SQLTransact-SQL 语句的相应权限。For Transact-SQLTransact-SQL statements that do not produce STATISTICS PROFILE result sets, only the appropriate permissions to execute the Transact-SQLTransact-SQL statements are required. 对于生成 STATISTICS PROFILE 结果集的 Transact-SQLTransact-SQL 语句,请确保既有 Transact-SQLTransact-SQL 语句执行权限又有 SHOWPLAN 权限,否则会中止执行 Transact-SQLTransact-SQL 语句,而 Showplan 信息也不会生成。For Transact-SQLTransact-SQL statements that do produce STATISTICS PROFILE result sets, checks for both the Transact-SQLTransact-SQL statement execution permission and the SHOWPLAN permission must succeed, or the Transact-SQLTransact-SQL statement execution is aborted and no Showplan information is generated.

另请参阅See Also

SET 语句 (Transact-SQL) SET Statements (Transact-SQL)
SET SHOWPLAN_ALL (Transact-SQL) SET SHOWPLAN_ALL (Transact-SQL)
SET STATISTICS TIME (Transact-SQL) SET STATISTICS TIME (Transact-SQL)
SET STATISTICS TIME (Transact-SQL)SET STATISTICS IO (Transact-SQL)