| title | sys.sp_xtp_control_proc_exec_stats (Transact-SQL) | ||
|---|---|---|---|
| description | Enables statistics collection for natively compiled stored procedures for the instance. | ||
| author | markingmyname | ||
| ms.author | maghan | ||
| ms.reviewer | randolphwest | ||
| ms.date | 06/23/2025 | ||
| ms.service | sql | ||
| ms.subservice | system-objects | ||
| ms.topic | reference | ||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| dev_langs |
|
[!INCLUDE sqlserver]
Enables statistics collection for natively compiled stored procedures for the instance.
To enable statistics collection at the query level for natively compiled stored procedures, see sys.sp_xtp_control_query_exec_stats.
sys.sp_xtp_control_proc_exec_stats
[ [ @new_collection_value = ] collection_value ]
, [ @old_collection_value = ] old_collection_value OUTPUT
[ ; ]
Determines whether procedure-level statistics collection is on (1) or off (0). @new_collection_value is bit.
@new_collection_value is set to zero when [!INCLUDE ssNoVersion] or the database starts.
Returns the current status. @old_collection_value is bit.
0 for success. Nonzero for failure.
Requires membership in the fixed sysadmin role.
To set @new_collection_value and query for the value of @new_collection_value:
EXECUTE sys.sp_xtp_control_proc_exec_stats @new_collection_value = 1;
DECLARE @c AS BIT;
EXECUTE sys.sp_xtp_control_proc_exec_stats
@old_collection_value = @c OUTPUT;
SELECT @c AS 'collection status';