Loading files into table

  • Hey all!

    I have ~700 files on a local hard drive that I need to have transferred into a table. Can I do this using only DTS, or would I have to write some .NET code to loop through all the files and save them?

    I already have the .NET functionality to save one file being uploaded by a user through a web interface, but this won't help me in taking all the files from the drive to the database.

    Any help getting me started with this is appreciated. Thanks in advance!

  • Since this is the TSQL board and since this is presumably an admin rather than production task [edit: I'm thinking of security issues in particular], I'll suggest

    select @strvar = 'dir "' + @filepath ... + '"'
    insert <table> exec xp_cmdshell  @strvar --to get files
     
    ...
     
       <cursor through <table> FOR UPDATE OF logging fields>
     
          <for each row:>
          (
          select @strvar = 'bcp ' + ... @filepath + @filename ...
          exec @retval = xp_cmdshell @strvar
          <update log fields>
          )
     

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

Viewing 2 posts - 1 through 1 (of 1 total)

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