Solved

Hard drive info

Posted on 2000-04-12
7
493 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
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

911 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

21 Experts available now in Live!

Get 1:1 Help Now