To find freespace of Database using a query

  • Good catch! Here is updated logic...

    EXEC @x = sp_OACreate 'Scripting.FileSystemObject', @iFSO OUT

    IF @x <> 0

    RETURN -1

    EXEC @x = sp_OAMethod @iFSO, 'GetDrive', @iDrive OUT, @cDrive

    IF @x <> 0

    GOTO Error

    EXEC @x = sp_OAGetProperty @iDrive, 'TotalSize', @vTotalSize OUT

    IF @x <> 0

    GOTO Error

    SET @iSizeMB = @vTotalSize/@biMB;

    EXEC @x = sp_OADestroy @iFSO;

    RETURN @iSizeMB;

    Error:

    EXEC @x = sp_OADestroy @iFSO

    RETURN -1

Viewing post 31 (of 30 total)

You must be logged in to reply to this topic. Login to reply