Skip to content

Latest commit

 

History

History
71 lines (55 loc) · 3.02 KB

cpu-busy-transact-sql.md

File metadata and controls

71 lines (55 loc) · 3.02 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
CPU_BUSY (Transact-SQL)
@@CPU_BUSY (Transact-SQL)
markingmyname
maghan
09/18/2017
sql
t-sql
reference
@@CPU_BUSY_TSQL
@@CPU_BUSY
CPU [SQL Server]
status information [SQL Server], CPU
ticks [SQL Server]
time [SQL Server], CPU activity
@@CPU_BUSY function
statistical information [SQL Server], CPU
CPU [SQL Server], activity
TSQL

@@CPU_BUSY (Transact-SQL)

[!INCLUDE SQL Server Azure SQL Managed Instance]

This function returns the amount of time that [!INCLUDEssNoVersion] has spent in active operation since its latest start. @@CPU_BUSY returns a result measured in CPU time increments, or "ticks." This value is cumulative for all CPUs, so it may exceed the actual elapsed time. To convert to microseconds, multiply by @@TIMETICKS.

Note

If the time returned in @@CPU_BUSY or @@IO_BUSY exceeds 49 days (approximately) of cumulative CPU time, you may receive an arithmetic overflow warning. In that case, the value of the @@CPU_BUSY, @@IO_BUSY and @@IDLE variables are not accurate.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

@@CPU_BUSY  

Return types

integer

Remarks

To see a report containing several [!INCLUDEssNoVersion] statistics, including CPU activity, run sp_monitor.

Examples

This example returns [!INCLUDEssNoVersion] CPU activity, as of the current date and time. The example converts one of the values to the float data type. This avoids arithmetic overflow issues when calculating a value in microseconds.

SELECT @@CPU_BUSY * CAST(@@TIMETICKS AS FLOAT) AS 'CPU microseconds',   
   GETDATE() AS 'As of' ;  

[!INCLUDEssResult]

CPU microseconds As of
---------------- -----------------------
18406250         2006-12-05 17:00:50.600

See also

sys.dm_os_sys_info (Transact-SQL)
@@IDLE (Transact-SQL)
@@IO_BUSY (Transact-SQL)
sp_monitor (Transact-SQL)
System Statistical Functions (Transact-SQL)