Click to See Complete Forum and Search --> : programmatically import from a text file


dmeikle
December 28th, 2003, 02:37 AM
I remember doing this back in school years ago, and how we whined that "we shouldn't need to know this, we'll just use a wizard in the workforce" (we were using Oracle back then at a command prompt).

well, it's bitten me on the butt. I need to write a section of the administrative application that can upload a text file, pipe delimited and import it into sql server 2000. I could write a huge chunk to split the file into a gazillion insert executions, but that wouldn't be very efficient, plus I have a bunch of sections that will need to do this.

Can someone show me some sample code on how to parse a text file into a table using an SQL statement?

ITGURU
December 30th, 2003, 11:17 PM
In Oracle you can achieve this by using Oracle SQL Loader but in SQL Server you have to perform this task either using some application which read your text file and generate insert statement for saving data in database or use DTS Services in which you have specified source and destination and even you can create a VB code for it or DTS Package and scheduled to be run at a fix interval.

Hope this will solve your problem.