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

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.