Dec 23, 2013

Sql script to get the IO time in sql server


Sql script to get the input output busy time in sql server since last time sql server had started.

SELECT @@IO_BUSY AS [IO Time]

Sample Output:

IO Time
120

To get in second:

SELECT @@IO_BUSY * CAST(@@TIMETICKS AS FLOAT) / 1000000 AS [IO Time(Second)]

To get the IO time during the execution of some sql queries:

DECLARE @IOTime AS INT
SET  @IOTime = @@IO_BUSY

/*
    Sql statements
*/

SELECT @@IO_BUSY -  @IOTime AS [IO Time]

No comments:

Post a Comment