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

    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
    In front of the computer
    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.


Posting Permissions

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