Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Posts
    12

    Unanswered: BULK insert from a text file name stored into a variable

    Hello I need to write a proc to load data from txt files I receive into a table. It works fine when I specify
    bulk insert.... from 'myfilename.txt'
    BUT my filename will always change and I store it into a variable @filename

    When I try to run the bulk insert instruction ... from @filename it doesn't work..
    do you know why?

    Thank you in advance

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Accoding to the destructions for BULK INSERT, it takes a literal string for the file name. To sidestep this requirement, you can resort to dynamic SQL using the EXECUTE character string syntax. It isn't pretty, but it should get the job done for you.

    -PatP

Posting Permissions

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