import text file to sql 2000

  • I have VB aplication that import Fixed length (Not delimited) text file in Sql server, using recordset but the process is very slow comparing to DTS. I need help on rewriting my apllication to use DTS with parameters as file name and file path.

    Thank you

  • aziz,

    There are many ways to get this done. IMHO the best, is to bcp the file into a table with one column (data varchar(4000)) and use substring(fieldname, startpos, length) to parse the data.

    Calling a DTS package has many drawbacks, including that your file will be dragged to the workstation running VB before it is loaded into the server. Faster than your looping over a recordset, but still slow with large files.

    A way around this is to kick off a job on your tartet server that will run the DTS package. If you decide to go this route, your VB application could make an entry in a table with your file path and file name, then the DTS package can do a lookup to load the values.

    If you really have your heart set on executing a DTS package from VB, you have to reference the Microsoft DTSPackageObjectLibrary. From the object model, you'll be able to assign values to the global variables in your DTS package. I belive there's sample code in the code section of this website, and plenty in MSDN to get you going.

    Good luck,

    John

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

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