Bringing Operating System File Information into SQL

  • I'm looking to capture inside a database some information regarding files and their sizes when they get created and analyze that over time.

    I've been trying to figure out a way to use the DIR command line command and parse the filename and filesize info into SQL but no luck yet.

    ANyone have any ideas on how to do this or offer alternative suggestions. 

    Am using DTS utility to capture the info.

     

    thks

     

  • You could use the filescriptingobject within vb in a dts.



    Shamless self promotion - read my blog http://sirsql.net

  • create table #T1 (file_info varchar(255))

    insert into #T1 exec master..xp_cmdshell 'dir *.*'

    drop table #T1

  •  EXEC master..xp_dirtree 'c:\mydir', 1, 1

    xp_dirtree is not documented in on-line help, but it does work.  Param 2 affects the search depth so 1 = current dir.  It returns files and directories which you can distinguish by each record's file attribute.  If you're using a UNC on a shared drive ensure you have network access privileges.

     

  • In addition to xp_dirtree, you can use xp_getfiledetails to return detailed information about a file or folder.

    eg: xp_getfiledetails 'C:\Temp\test.txt'

    --------------------
    Colt 45 - the original point and click interface

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply