Solved

Hard drive info

Posted on 2000-04-12
7
499 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
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.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

691 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