Posts

Showing posts from November, 2012

Get SQL Server free disk information without admin privileges

Following script will get the free disk space in database server. To run this script following permissions are required. "NO sysadmin" privileges are required.

Permissions Required

GRANT execute on sp_OAGetErrorInfo to UuerUser
GRANT execute on sp_OAGetProperty to UuerUser
GRANT execute on sp_OACreate to UuerUser
GRANT execute on sp_OADestroy to UuerUser

Script

declare @RunLocal bit = 1;

DECLARE @DiskSpaceStats TABLE
(
DriveLetterchar(1),
TotalSizedecimal(20,0),
AvailableBytesdecimal(20,0),
DriveTypechar(10),
PercentFreedecimal(18,3),
Report_Datedatetime default getdate()
)

DECLARE @DiskSpace TABLE
(
RowID int Identity Primary Key,
DriveLetter char(1),
TotalSize decimal(20,0),
AvailableBytes decimal(20,0),
DriveType char(10),
PercentFree decimal(18,3)
)

DECLARE @counter int
DECLARE @FSOobject int
DECLARE @RecordCount int
DECLARE @count int
DECLARE @string  char(35)
DECLARE @DriveLetter char(1)
DECLARE @TotalSize char(50)
DECLARE @AvailableSpace char(50)
DECLARE @DriveType char(10)
DECLARE…