Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2003
    Posts
    8

    Unanswered: Insert a textfile into a SQL DB

    Assuming I have a comma delimited textfile that corresponds in columns and data types to the table I want to insert into, how do i do the insert using a stored procedure?
    Last edited by eWW; 01-24-03 at 09:06.

  2. #2
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    Lookup "Bulk Insert" in Books Online.
    Paul Young
    (Knowledge is power! Get some!)

  3. #3
    Join Date
    Dec 2002
    Posts
    1,245

    Re: Insert a textfile into a SQL DB

    As an alternative, you can also use a DTS package. However, I think BULK INSERT is a better option. And as soon as I learn how to use it, I will get off of my DTS crutch.

    Regards,

    Hugh Scott

  4. #4
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    Every problem has many solutions, some better then others. In general DTS is a good thing and MUCH more flexable than bulk insert!
    Paul Young
    (Knowledge is power! Get some!)

  5. #5
    Join Date
    Jan 2003
    Posts
    8
    I appreciate the flexibility of DTS and am baffled by its complexity if I want to influence it from the outside.

    I am working on a webapplication where the user should be able to upload an extract of his database and integrate it into the database of my application. Working with ASP I can call a stored procedure and I can allocate the fields in the textfile to the columns in my SQL DB by sending parameters. With this I can dynamically allocate the users fields to my columns.

    While I can use DTS manually, I have no clue as to how to use it dynamically. So I figured I'd use the stored procedure approach. But now I need to somehow access the lines of the textfile to insert them into my table.

  6. #6
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    Again, checkout Books Online, formulate a plan and post back any questions.
    Paul Young
    (Knowledge is power! Get some!)

  7. #7
    Join Date
    Jan 2003
    Posts
    8
    Looks like I don't have bulkadmin or sysadmin rights on the server. The provider does not seem willing to change that.

    Any other ideas?

  8. #8
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    BCP from the command line, your provider may have turned this off.
    DTS, although I don't know this well enough to say if you will run into security problems,
    Write an app to insert one row at a time.
    Paul Young
    (Knowledge is power! Get some!)

Posting Permissions

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