SQL @@IDLE Statistical Function returns the total idle time of this SQL Server since it last began. Syntax behind this is @@IDLE is
@@IDLE
SQL @@IDLE Example
The code snippet below shows the total idle time since this SQL Server last started. Learn more about SQL GETDATE from our SQL tutorial page.
SELECT @@IDLE AS 'Idle Time'

You can use SQL @@TIMETICKS to get the idle time in microseconds. Next, we used the GETDATE() function to see the total idle time until today. Also, refer to the SQL @@CONNECTIONS article.
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'
