declare @driveletter CHAR(1)
set @driveletter ='c'
BEGIN
DECLARE @rs INTEGER, @fso INTEGER, @getdrive VARCHAR(13),
@drv INTEGER, @drivesize varchar(20)
SET @getdrive = 'GetDrive("' + @driveletter + '")'
EXEC @rs = sp_OACreate 'Scripting.FileSystemObject', @fso OUTPUT
IF @rs = 0
EXEC @rs = sp_OAMethod @fso, @getdrive, @drv OUTPUT
IF @rs = 0
EXEC @rs = sp_OAGetProperty @drv,'TotalSize', @drivesize OUTPUT
IF @rs<> 0
EXEC sp_OADestroy @drv
EXEC sp_OADestroy @fso
select cast(cast(@drivesize as decimal) /1024 /1024/1024 as decimal(6,2))
END
No comments:
Post a Comment