SP:Recompile 事件类SP:Recompile Event Class

适用对象:是SQL Server 是Azure SQL 数据库 否Azure Synapse Analytics (SQL DW) 否并行数据仓库APPLIES TO: yesSQL Server yesAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

SP:Recompile 事件类指示存储过程、触发器或用户定义的函数已被重新编译。The SP:Recompile event class indicates that a stored procedure, trigger, or user-defined function has been recompiled. 此事件类报告的重新编译在语句级上发生。Recompilations reported by this event class occur at the statement level.

跟踪语句级重新编译的首选方法是使用 SQL:StmtRecompile 事件类。The preferred way to trace statement-level recompilations is to use the SQL:StmtRecompile event class. 已弃用 SP:Recompile 事件类。The SP:Recompile event class is deprecated. 有关详细信息,请参阅 SQL:StmtRecompile Event ClassFor more information, see SQL:StmtRecompile Event Class.

SP:Recompile 事件类的数据列SP:Recompile Event Class Data Columns

数据列名称Data column name Data typeData 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
EventClassEventClass intint 事件类型 = 37。Type of event = 37. 2727 No
EventSequenceEventSequence intint 特定事件在请求中的顺序。The sequence of a given event within the request. 5151 No
EventSubClassEventSubClass intint 事件子类的类型。Type of event subclass. 指示重新编译的原因。Indicates the reason for recompilation.

1 = 架构已更改1 = Schema Changed

2 = 统计已更改2 = Statistics Changed

3 = 重新编译 DNR3 = Recompile DNR

4 = 所设置的选项已更改4 = Set Option Changed

5 = 临时表已更改5 = Temp Table Changed

6 = 远程行集已更改6 = Remote Rowset Changed

7 = 浏览 Perm 的方式已更改7 = For Browse Perms Changed

8 = 查询通知环境已更改8 = Query Notification Environment Changed

9 = MPI 视图已更改9 = MPI View Changed

10 = 游标选项已更改10 = Cursor Options Changed

11 = 使用重新编译选项11 = With Recompile Option
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. 如果客户端提供了主机名,则填充此数据列。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 = 系统,0 = 用户。1 = system, 0 = user. 6060 Yes
LoginNameLoginName nvarcharnvarchar 用户的登录名( SQL ServerSQL Server 安全登录名或 MicrosoftMicrosoft Windows 登录凭据,格式为“DOMAIN\username”)。Name of the login of the user (either SQL ServerSQL Server security login or the MicrosoftMicrosoft Windows login credentials in the form of DOMAIN\username). 1111 Yes
LoginSidLoginSid 图像image 登录用户的安全标识号 (SID)。Security identification number (SID) of the 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. 2929 Yes
NTDomainNameNTDomainName nvarcharnvarchar 用户所属的 Windows 域。Windows domain to which the user belongs. 77 Yes
NTUserNameNTUserName nvarcharnvarchar Windows 用户名。Windows user name. 66 Yes
ObjectIDObjectID intint 系统分配的存储过程 ID。System-assigned ID of the stored procedure. 2222 Yes
ObjectNameObjectName nvarcharnvarchar 触发重新编译的对象的名称。Name of the object that triggered the recompile. 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 instance of 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。ID of the session on which the event occurred. 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 Yes
StartTimeStartTime datetimedatetime 该事件(如果存在)的启动时间。Time at which the event started, if available. 1414 Yes
TextDataTextData ntextntext 导致语句级重新编译的 Transact-SQL 语句文本。Text of the Transact-SQL statement that caused a statement-level recompilation. 11 Yes
TransactionIDTransactionID bigintbigint 系统分配的事务 ID。System-assigned ID of the transaction. 44 Yes
XactSequenceXactSequence bigintbigint 用于说明当前事务的标记。Token used to describe the current transaction. 5050 Yes

另请参阅See Also

sp_trace_setevent (Transact-SQL) sp_trace_setevent (Transact-SQL)
SQL:StmtRecompile Event ClassSQL:StmtRecompile Event Class