DECLARE @hr INT , 
    @fso INT, 
    @drive CHAR(1)='F',  /* To demonstrate have hard coded the drive letter to F */
    @odrive INT,
    @TotalSize BIGINT,
    @freespace BIGINT,
    @AvailableSpace   BIGINT,
    @DriveCollection INT,
    @DriveCount INT,
    @FileSystemInstance  INT,
    @volumeName varchar(128),
    @IsReady VARCHAR(5)
  EXEC sp_OACreate 'Scripting.FileSystemObject',@fso OUT
  EXEC sp_OAMethod @fso,'GetDrive', @odrive OUT, @drive 
  EXEC sp_OAGetProperty @odrive,'TotalSize', @TotalSize OUT
  EXEC sp_OAGetProperty @odrive,'freespace', @freespace OUT
  EXEC sp_OAGetProperty @odrive,'AvailableSpace', @AvailableSpace OUT
  EXEC sp_OAGetProperty @fso,'Drives', @DriveCollection OUT
  EXEC sp_OAGetProperty @DriveCollection,'Count', @DriveCount OUT
  EXEC sp_OAGetProperty @odrive,'VolumeName', @volumeName OUT
  EXEC sp_OAGetProperty @odrive,'isReady', @IsReady OUT

  SELECT
  @DriveCount driveCount
  ,@Drive DriveLetter,
  (@AvailableSpace/1048576)/1024 FreeSpace,
  @volumeName Volumne,
  @IsReady DriveStatus,
  (@TotalSize/1048576)/1024.00 TotalSize,
  (@freespace/1048576)/1024.00 FreeSpace

 

相关文章:

  • 2021-09-21
  • 2021-09-28
  • 2021-11-06
  • 2021-07-27
  • 2022-12-23
  • 2021-08-28
  • 2021-07-01
  • 2021-12-02
猜你喜欢
  • 2021-07-16
  • 2021-11-17
  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
相关资源
相似解决方案