SQL:StmtRecompile 事件类SQL:StmtRecompile Event Class

适用于: 是SQL Server是Azure SQL 数据库否Azure SQL 数据仓库否并行数据仓库APPLIES TO: yesSQL Server yesAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

SQL:StmtRecompile 事件类指示由下列所有类型的批处理引起的语句级重新编译:存储过程、触发器、即席批查询和查询。The SQL:StmtRecompile event class indicates statement-level recompilations caused by all types of batches: stored procedures, triggers, ad hoc batches, and queries. 可以通过使用 sp_executesql、动态 SQL、“准备”方法、“执行”方法或类似接口来提交查询。Queries can be submitted by using sp_executesql, dynamic SQL, Prepare methods, Execute methods, or similar interfaces. 应使用 SQL:StmtRecompile 事件类而不是 SP:Recompile 事件类。The SQL:StmtRecompile event class should be used instead of the SP:Recompile event class.

SQL:StmtRecompile 事件类的数据列SQL:StmtRecompile Event Class Data Columns

数据列名称Data column name 数据类型Data type 描述Description 列 IDColumn ID 可筛选Filterable
ApplicationNameApplicationName nvarcharnvarchar 客户端应用程序的名称,该客户端应用程序创建了指向 MicrosoftMicrosoft SQL ServerSQL Server实例的连接。Name of the client application that created the connection to an instance of MicrosoftMicrosoft SQL ServerSQL Server. 该列由应用程序传递的值填充,而不是由所显示的程序名填充。This column is populated with the values passed by the application rather than the displayed name of the program 1010 用户帐户控制Yes
ClientProcessIDClientProcessID intint 主机为运行该客户端应用程序的进程分配的 ID。ID assigned by the host computer to the process where the client application is running. 如果客户端提供了进程 ID,则填充此数据列。This data column is populated if the client provides the process ID. 99 用户帐户控制Yes
DatabaseIDDatabaseID intint 正在运行存储过程的数据库的 ID。ID of the database in which the stored procedure is running. 可使用 DB_ID 函数来确定数据库的值。Determine the value for a database by using the DB_ID function. 33 用户帐户控制Yes
DatabaseNameDatabaseName nvarcharnvarchar 正在运行存储过程的数据库的名称。Name of the database in which the stored procedure is running. 3535 用户帐户控制Yes
EventSequenceEventSequence intint 事件在请求中的顺序。The sequence of an event within the request. 5151 No
EventSubClassEventSubClass intint 说明重新编译的原因:Describes the cause of the recompilation:

1 = 架构的更改1 = Schema changed

2 = 统计信息的更改2 = Statistics changed

3 = 编译的延迟3 = Deferred compile

4 = 设置选项的更改4 = Set option changed

5 = 临时表的更改5 = Temp table changed

6 = 远程行集的更改6 = Remote rowset changed

7 = For Browse 权限的更改7 = For Browse permissions changed

8 = 查询通知环境的更改8 = Query notification environment changed

9 = 分区视图的更改9 = Partition view changed

10 = 游标选项的更改10 = Cursor options changed

11 = 已请求选项(重新编译)11 = Option (recompile) requested
2121 用户帐户控制Yes
GroupIDGroupID intint 在其中激发 SQL 跟踪事件的工作负荷组的 ID。ID of the workload group where the SQL Trace event fires. 6666 用户帐户控制Yes
HostNameHostName nvarcharnvarchar 运行提交此语句的客户端的计算机名称。Name of the computer on which the client is running which submitted this statement. 如果客户端提供了主机名,则填充此数据列。This data column is populated if the client provides the host name. 若要确定主机名,请使用 HOST_NAME 函数。To determine the host name, use the HOST_NAME function. 88 用户帐户控制Yes
IntegerData2IntegerData2 intint 在存储过程或批处理中导致重新编译的语句的终止偏移量。Ending offset of the statement within the stored procedure or batch that caused recompilation. 如果该语句是其所在批处理中的最后一个语句,则终止偏移量是 -1。Ending offset is -1 if the statement is the last statement in its batch. 5555 用户帐户控制Yes
IsSystemIsSystem intint 指示事件是发生在系统进程中还是发生在用户进程中。Indicates whether the event occurred on a system process or a user process.

1 = 系统1 = system

0 = 用户0 = user
6060 用户帐户控制Yes
LineNumberLineNumber intint 此语句在批处理中的序列号(如果适用)。Sequence number of this statement within the batch, if applicable. 55 用户帐户控制Yes
LoginNameLoginName nvarcharnvarchar 提交此批处理所用的登录名。Name of the login that submitted this batch. 1111 用户帐户控制Yes
LoginSidLoginSid 图像image 当前登录用户的安全标识符 (SID)。Security identifier (SID) of the currently logged in user. 您可以在 sys.server_principals 目录视图中找到此信息。You can find this information in the sys.server_principals catalog view. 服务器中的每个登录名都具有唯一的 SID。Each SID is unique for each login in the server. 4141 用户帐户控制Yes
NestLevelNestLevel intint 存储过程调用的嵌套级别。The nesting level of the stored procedure call. 例如,my_proc_a 存储过程调用 my_proc_b。For example, my_proc_a stored procedure calls my_proc_b. 在此示例中,my_proc_a 的 NestLevel 为 1,而 my_proc_b 的 NestLevel 为 2。In this case, my_proc_a has a NestLevel of 1, my_proc_b has a NestLevel of 2. 2929 用户帐户控制Yes
NTDomainNameNTDomainName nvarcharnvarchar 用户所属的 Windows 域。Windows domain to which the user belongs. 77 用户帐户控制Yes
NTUserNameNTUserName nvarcharnvarchar 连接用户的 Windows 用户名。Windows user name of connected user. 66 用户帐户控制Yes
ObjectIDObjectID intint 系统分配的对象标识符,包含引起重新编译的语句。System-assigned identifier of the object that contains the statement that caused the recompilation. 此对象可以是存储过程、触发器或用户定义函数。This object can be a stored procedure, trigger, or user-defined function. 对于即席批查询或已准备好的 SQL,ObjectID 和 ObjectName 将返回一个 NULL 值。For ad hoc batches or prepared SQL, ObjectID and ObjectName return a NULL value. 2222 用户帐户控制Yes
ObjectNameObjectName nvarcharnvarchar ObjectID 标识的对象的名称。Name of the object identified by ObjectID. 3434 用户帐户控制Yes
ObjectTypeObjectType intint 表示事件中涉及的对象类型的值。Value that represents the type of object involved in the event. 有关详细信息,请参阅 ObjectType Trace Event ColumnFor more information, see ObjectType Trace Event Column. 2828 用户帐户控制Yes
OffsetOffset intint 在存储过程或批处理中导致重新编译的语句的起始偏移量。Starting offset of the statement within the stored procedure or batch that caused recompilation. 6161 用户帐户控制Yes
RequestIDRequestID intint 包含该语句的请求的 ID。ID of the request containing the statement. 4949 用户帐户控制Yes
ServerNameServerName nvarcharnvarchar 正在跟踪的 SQL ServerSQL Server 的名称。Name of the SQL ServerSQL Server being traced. 2626 No
SessionLoginNameSessionLoginName nvarcharnvarchar 发起会话的用户的登录名。Login name of the user who originated the session. 例如,如果您使用 Login1 连接到 SQL ServerSQL Server ,再以 Login2 的身份执行语句,则 SessionLoginName 将显示 Login1,而 LoginName 将显示 Login2。For example, if you connect to SQL ServerSQL Server using Login1 and execute a statement as Login2, SessionLoginName shows Login1 and LoginName shows Login2. 此列将同时显示 SQL ServerSQL Server 登录名和 Windows 登录名。This column displays both SQL ServerSQL Server and Windows logins. 6464 用户帐户控制Yes
SPIDSPID intint 连接的服务器进程 ID。Server process ID of the connection. 1212 用户帐户控制Yes
SqlHandleSqlHandle varbinaryvarbinary 基于即席查询文本或 SQL 对象的数据库和对象 ID 的 64 位哈希运算。64-bit hash based on the text of an ad hoc query or the database and object ID of an SQL object. 可以将该值传递到 sys.dm_exec_sql_text 以检索关联的 SQL 文本。This value can be passed to sys.dm_exec_sql_text to retrieve the associated SQL text. 6363 No
StartTimeStartTime datetimedatetime 该事件(如果存在)的启动时间。Time at which the event started, if available. 1414 用户帐户控制Yes
TextDataTextData ntextntext 重新编译的 Transact-SQL 语句的文本。Text of the Transact-SQL statement that recompiled. 11 用户帐户控制Yes
TransactionIDTransactionID bigintbigint 系统分配的事务 ID。System-assigned ID of the transaction. 44 用户帐户控制Yes
XactSequenceXactSequence bigintbigint 用于说明当前事务的标记。Token that describes the current transaction. 5050 用户帐户控制Yes

另请参阅See Also

SP:Recompile 事件类 SP:Recompile Event Class
sp_trace_setevent (Transact-SQL)sp_trace_setevent (Transact-SQL)