Results 1 to 5 of 5

Thread: How to return 'Free Space' value?.....

  1. #1
    Join Date
    Mar 2003
    Posts
    383

    How to return 'Free Space' value?.....

    Hi, I have linked to 50 servers and use dynamic query (exec @sqlString8000)...
    to get info about 1000 databases.

    Now I wand to use xp_cmdshell to check each server C:\ fress space, how could I return the last 2nd line value to a global ##temp table?

    <<5 Dir(s) 2,169,880,576 bytes free>>
    <<NULL>>
    thanks
    -D

  2. #2
    Join Date
    Sep 2002
    Posts
    169
    The following should get you started :

    create table #DirListing
    (DirListingID int identity (1, 1),
    Dirlist varchar (500))

    Insert Into #DirListing
    Exec Master..xp_cmdshell 'dir c:'


    Insert Into ##Temp
    Select DirList From #DirListing DL
    Where DL.DirListingID = (Select Max (DL2.DirListingID) From #DirListing DL2) - 1

  3. #3
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You can use sp_OACreate to get the drive information from FileSystemObject.

    This one uses vbscript and WMI, but you can call it from t-sql using sp_oacreate.

    http://www.microsoft.com/technet/scr...s_fsd_rrhv.asp

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    With this number of servers, better to use server management tool to monitor them.

  5. #5
    Join Date
    Mar 2003
    Posts
    383

    it works...

    It works. Stephen, good tip, especially by using the dirListingID = max - 1 to retrieve the last second line value.

    thanks for all of you.
    -D

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •