Exec in shellto change text values3/26/2023 SELECT t.*ĬROSS APPLY sys.dm_exec_sql_text(r.sql_handle) AS t In this example the spid happens to be 59. Open a new query window and pass the spid identified in step 1. The sql_handle from sys.dm_exec_requests will be passed to sys.dm_exec_sql_text using CROSS APPLY. The following is a basic example to illustrate passing a sql_handle either directly or with CROSS APPLY.Įxecute the following T-SQL in a new query window in SQL Server Management Studio. To determine dbid for ad hoc queries, use plan_handle instead. Plan handle is a hash value derived from the compiled plan of the entire batch.ĭbid cannot be determined from sql_handle for ad hoc queries. Remarksįor ad hoc queries, the SQL handles are hash values based on the SQL text being submitted to the server, and can originate from any database.įor database objects such as stored procedures, triggers or functions, the SQL handles are derived from the database ID, object ID, and object number. Requires VIEW SERVER STATE permission on the server. For more information, see sys.numbered_procedures (Transact-SQL). Is NULL for ad hoc and prepared SQL statements.įor a numbered stored procedure, this column returns the number of the stored procedure. Sys.dm_exec_procedure_stats (Transact-SQL)įor static SQL in a stored procedure, the ID of the database containing the stored procedure. The plan_handle can be obtained from the following dynamic management objects: Is a token that uniquely identifies a query execution plan for a batch that has executed and its plan resides in the plan cache, or is currently executing. The sql_handle can be obtained from the following dynamic management objects: Is a token that uniquely identifies a batch that has executed or is currently executing. Syntax sys.dm_exec_sql_text(sql_handle | plan_handle) This table-valued function replaces the system function fn_get_sql. Returns the text of the SQL batch that is identified by the specified sql_handle. Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |