Call now: (800) 766-1884  



 Home


 SQL Server Tips
 SQL Server Training

 SQL Server Consulting
 SQL Server Support
 SQL Server Remote DBA



 Articles
 Services
 SQL Server Scripts
 Scripts Menu



 

 

 

   
  SQL Server Tips by Gama and Naughter

Implementation

The XP calls the function GetDiskFreeSpaceEx to obtain information about the amount of space available on a disk volume. GetDiskFreeSpaceEx has four parameters: the first one is the path for a directory on the disk to be examined; this is a pointer to a null-terminated string. The second is the total number of free bytes on the disk and this is a pointer to an unsigned large integer (64 bits). The third is the total number of available bytes on the disk and this is a pointer like the one for the second parameter. Finally, the fourth is the total number of free bytes on the disk and this is a pointer like the ones from parameters two and three. XP_DISKSPACE will divide the number of free bytes on the disk by 1,048,576 (2 to the 20th power); this will result in a value measured in megabytes.

The DLL exposes 1 XP using the following XP++ code:

IMPLEMENT_XP(XP_DISKSPACE, CDiskSpaceExtendedStoredProcedure)

This is the code for calling GetDiskFreeSpaceEx and calculating the result in megabytes:

ULARGE_INTEGER i64FreeBytesToCaller;
ULARGE_INTEGER i64TotalBytes;
ULARGE_INTEGER i64FreeBytes;
BOOL bSuccess = GetDiskFreeSpaceEx(pszDriveLetter, &i64FreeBytesToCaller, &i64TotalBytes, &i64FreeBytes);
if (bSuccess)
{
DBINT nSpaceLeft = (DBINT) (((__int64) i64FreeBytes.QuadPart) / 1048576);


The above book excerpt is from:

Super SQL Server Systems
Turbocharge Database Performance with C++ External Procedures

ISBN: 0-9761573-2-2
Joseph Gama, P. J. Naughter

 http://www.rampant-books.com/book_2005_2_sql_server_external_procedures.htm  

   

 

Burleson Consulting Remote DB Administration


 

 


 

 

 

 

 
Burleson is the America's Team

Note: The pages on this site were created as a support and training reference for use by our staff of DBA consultants.  If you find it confusing, please exit this page.

Errata?  SQL Server technology is changing and we strive to update our SQL Server support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:and include the URL for the page.
 


Burleson Consulting
SQL Server database support

 

Copyright 1996 -  2013 by Vaaltech Web Services. All rights reserved.

Hit Counter