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:
01685858
Views:
46
>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.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform