SQL @@IDLE Statistical Function returns the total idle time of this SQL Server since it last began. Syntax behind this is @@IDLE is


SQL @@IDLE Example

Below code snippet shows the total idle time since this SQL Server last started.

SELECT @@IDLE AS 'Idle Time'
SQL @@IDLE Example 1

You can use @@TIMETICKS to get the idle time in microseconds. Next, we used the GETDATE() function to see the total idle time until today.

SELECT @@CONNECTIONS AS [Total Log In Attempts],
SELECT @@IDLE AS 'Idle Time',
       @@IDLE * CAST(@@TIMETICKS AS FLOAT) AS 'Idle Time in Microseconds',
       GETDATE() AS 'As Of Today'
SQL @@IDLE Example 2
Categories SQL