Help with importing data

greenspun.com : LUSENET : SQL Server Database Administration : One Thread

What is the best way to import data from foxpro into SQL server 6.5?

Right now, I created a database container in VFP6.0 and created remote connections to SQL....it seem kind of slow...i was wondering if you knew of a better way...

Thanks

-- Anonymous, September 11, 1998

Answers

Re: Importing from Foxpro

Sean,

Here are a few ideas gleaned from usenet. (Please pardon me if these ideas are redundant or the same as what you have already used. I am not familiar with the Foxpro terminology.)

One way to do this would be to: (a) Export the DBF file to text from Foxpro (b) Use the SQL Server BCP utility to move the data in to SQL Server.

Or... try running an ODBC connection to the database; SET LIBR TO FPSQL gnhandle = dbconnect(<'ODBC DATA SOURCE NAME'>,<'userid'>,<'password'>)

then loop through the table issuing inserts into database

lcSQL = "INSERT values(" + +', '+...+")" lnreturn = dbexec(gnhandle,lcSQL)

This will work faster than BCP and you will have more control over data column conversions.

Or... you can also just create a remote view in VFP and copy the data directly to SQL Server. Finally, VFP has an upsizing wizard to copy the table for you, if you first put it in a VFP database.

Or... use the FoxPro to SQL Server ODBC and write a function like this from within a FoxPro PRG:

*** create a Remote updatable View into SQL Server called SQLView

USE FOXDATA.DBF in 0

DO WHILE NOT EOF() INSERT INTO TABLE SQLView(FOXDATA.fld1, FOXDATA.fld2, FOXDATA.fld3) VALUES(934934434,"Michelin Inc.","12/21/97") =tableupdate(1,.T.,"SqlView") skip ENDDO

The ODBC translation layer handles all of the data type conversions....

Good luck.

Eric

-- Anonymous, September 12, 1998


Moderation questions? read the FAQ