Solved

Hard drive info

Posted on 2000-04-12
7
492 Views
Last Modified: 2012-08-14
I'm new to SQL and want to write a stored proc that will allow me to get info about the machine I'm working on. I want to get: 1) partition size(s) of the hard drive as well and 2) total space occupied by files in directory a directory. I know I can do a xp_cmdshell ‘dir c:\xyz’ but this is for many remote machines in our system and I really don't need all the information a ‘dir’ or ‘chkdisk’command would return. Any suggestions?
0
Comment
Question by:Grailman
7 Comments
 
LVL 4

Expert Comment

by:mitek
ID: 2708403
check out these stored procedures:

xp_fixeddrives

xp_dirtree

xp_subdirs

sp_spaceused


also, you can read values directly from registry. this is probably the most precise way to find out the sizes of partitions and just about any information about the machine...
0
 
LVL 1

Author Comment

by:Grailman
ID: 2708467
Thanks for the quick reply.

I'm using SQL7 but I couldn't find these three:
   xp_fixeddrives
   xp_dirtree
   xp_subdirs

and this one:
   sp_spaceused

looks like it is only for db info. I actually need to query file info.
0
 
LVL 4

Accepted Solution

by:
Gustavo Perez Buenrostro earned 200 total points
ID: 2708508
Grailman,

As mitek suggested you could use these extended stored procedures to get the information you request. Note you should be careful when using undocumented extended stored procedures because there are no info and helpful hints available on how to use them.

You can get a complete list of some undocumented extended stored procedures at:

http://www.winntmag.com/Files/3539/Table_01.html

PD: Let me know if you need advice on how to use them.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 7

Expert Comment

by:simonsabin
ID: 2708520
The machine your working on, does that mean the machine that is running SQL Server
0
 
LVL 1

Author Comment

by:Grailman
ID: 2709147
The two procs
   xp_fixeddrives
   xp_availablemedia

get the free space alright but I also need space used as well.
0
 
LVL 4

Expert Comment

by:mitek
ID: 2711979
gpbuenrostro -- thanks for the link.

ok. i sort of had left my answer unfinished. my idea was to read the values from nt registry using some of those undocumented sp from gpbuenrostro's link.

sorry, i'm not an nt guru, so i don't know where exactly the free/used space parameters are located in the registry; this goes beyond the area of sql server expertise. but i think my idea is clear.



0
 
LVL 1

Author Comment

by:Grailman
ID: 2712090
gpbuenrostro:
Thanks for the link. This does not fully work in my current situation but those are some great stored procedures that I know I'll use.

mitek:
I don't think that these parameters are actually in the registry. I've searched in it for free, partition & space but have not been able to find them :-( Thanks anyway.

0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now