?
Solved

T-SQL System Info

Posted on 2010-03-23
1
Medium Priority
?
407 Views
Last Modified: 2012-08-13
I have multiple servers on the network (10.0.0.10; 10.0.0.11; 10.0.0.12; etc...) and I would like to add the following information to a database record (per server) running a stored procedure from SQL Server 2005 located on 10.0.0.10:

Server Name
IP Address
Total Disk Capacity
Free Disk Space
Directory Names and Number of Files and Disk Usage per directory
0
Comment
Question by:conrad2010
1 Comment
 
LVL 12

Accepted Solution

by:
Chris M earned 2000 total points
ID: 28423398
Hi,
You could write a stored procedure which executes commands at the OS command line using xp_cmdshell to retrieve these details.

There are however limitations with just using a procedure to do all these tasks.
You can get the host name using ping command and reading the results e.g:
PING -n 1 -a 10.0.0.11

So passing it in a procedure would need writing SQL like this:
EXECUTE master..xp_cmdshell 'ping -n 1 -a 10.0.0.11';

So getting server name and IP address can be done locally from your database server but tasks like getting details like Total Disk Capacity, Free Disk Space, Directory Names and Number of Files and Disk Usage per directory definitely will require running commands locally on the different servers/hosts whose details you're trying to get. This means that a procedure will therefore not achieve this.

It's best that you write an application for these tasks. You could think of writing an application in any of your favorite programming language e.g dot Net (C#, VB etc) or Java which can be do all these tasks for you and then write details into SQL server by connecting to your database.

All the best,
Chris Musasizi

0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Question has a verified solution.

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

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses

601 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