Skip to content

Latest commit

 

History

History
67 lines (53 loc) · 2.67 KB

idle-transact-sql.md

File metadata and controls

67 lines (53 loc) · 2.67 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
@@IDLE (Transact-SQL)
@@IDLE (Transact-SQL)
markingmyname
maghan
09/18/2017
sql
t-sql
reference
@@IDLE_TSQL
@@IDLE
time [SQL Server], idle
ticks [SQL Server]
@@IDLE function
status information [SQL Server], idle time
idle time [SQL Server]
TSQL

@@IDLE (Transact-SQL)

[!INCLUDE SQL Server Azure SQL Managed Instance]

Returns the time that [!INCLUDEssNoVersion] has been idle since it was last started. The result is in CPU time increments, or "ticks," and is cumulative for all CPUs, so it may exceed the actual elapsed time. Multiply by @@TIMETICKS to convert to microseconds.

Note

If the time returned in @@CPU_BUSY, or @@IO_BUSY exceeds approximately 49 days of cumulative CPU time, you receive an arithmetic overflow warning. In that case, the value of @@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

@@IDLE  

Return Types

integer

Remarks

To display a report containing several [!INCLUDEssNoVersion] statistics, run sp_monitor.

Examples

The following example shows returning the number of milliseconds [!INCLUDEssNoVersion] was idle between the start time and the current time. To avoid arithmetic overflow when converting the value to microseconds, the example converts one of the values to the float data type.

SELECT @@IDLE * CAST(@@TIMETICKS AS float) AS 'Idle microseconds',  
   GETDATE() AS 'as of';  

[!INCLUDEssResult]

I  
Idle microseconds  as of                   
----------------- ----------------------  
8199934           12/5/2006 10:23:00 AM   

See Also

@@CPU_BUSY (Transact-SQL)
sp_monitor (Transact-SQL)
@@IO_BUSY (Transact-SQL)
System Statistical Functions (Transact-SQL)