Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bulk insert VFP table to SQL with memo fields?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01685857
Message ID:
01685859
Views:
39
>>Is there a way to perform a bulk insert from a VFP table to SQL table if the VFP table has memo fields?
>>
>>I know I can take a VFP table, copy it to a .csv file, and then bulk insert that -- but of course I can't get the memo fields in the .csv file.
>>
>>Thanks!
>
>This probably does not exactly answer your question. But I routinely have to do it. And I always create a small .PRG file and insert records to the SQL server, as follows (one example):
>
>  TEXT TO cSqlInsert NOSHOW
>      INSERT INTO STAFF
>      ( EMPLOYEE, EMPL_NAME, CLASS, ST_RATE, OT_RATE, ST_WAGE, OT_WAGE, ADDRESS1, ADDRESS2,
>CITY, STATE, ZIP, PHONE, DATE_VIEW, DATE_HIRE, WAGE, SHOP, STATUS, DOB,
>DT_RATE, DT_WAGE, ST_ACCOUNT, OT_ACCOUNT, DT_ACCOUNT, NOTES, SHOP_PK, PAGE_NO, EMPL_EMAIL, SITE_NO, REC_ID, VFP_EMPL_PK, CC_EMAIL )
>      VALUES 
>      ( ?STAFF.EMPLOYEE, ?STAFF.EMPL_NAME, ?STAFF.CLASS, ?STAFF.ST_RATE, ?STAFF.OT_RATE, ?STAFF.ST_WAGE, ?STAFF.OT_WAGE, ?STAFF.ADDRESS1, ?STAFF.ADDRESS2,
>?STAFF.CITY, ?STAFF.STATE, ?STAFF.ZIP, ?STAFF.PHONE, ?EVL(STAFF.DATE_VIEW,NULL), ?EVL(STAFF.DATE_HIRE,NULL), ?STAFF.WAGE, ?cShopId, ?STAFF.STATUS, ?EVL(STAFF.DOB,NULL),
>?STAFF.DT_RATE, ?STAFF.DT_WAGE, ?STAFF.ST_ACCOUNT, ?STAFF.OT_ACCOUNT, ?STAFF.DT_ACCOUNT, ?STAFF.NOTES, ?STAFF.SHOP_PK, ?STAFF.PAGE_NO, ?STAFF.EMPL_EMAIL, ?STAFF.SITE_NO, ?STAFF.REC_ID, ?STAFF.EMPL_PK, ?STAFF.CC_EMAIL ) 
>   ENDTEXT
>
>	SELECT STAFF
>	DO WHILE !EOF()
>	       nResult = SQLEXEC(hCon, cSqlInsert)	
>				
>		IF nResult < 1
>			AERROR( aErrorInf )
>		       *-- do something with the error
>             endif
>
>           skip
>
>     ENDDO
>
>
>
>And with the above, it does not matter what type is VFP field.
>
>HTH.

Yes that works for what it's doing -- but that will be no faster than the way I'm doing it now -- 1 record at a time with remote views. The SQL BULK INSERT command works really fast. It takes me 45 minutes to do what I'm doing 1 record at a time vsless than 1/2 a second to do it with a BULK INSERT lol.
ICQ 10556 (ya), 254117
Previous
Reply
Map
View

Click here to load this message in the networking platform