local lcInsertFirst, lcInsertLast local lcOutFileName, lcTemp, hin, hout lcInsertFirst = sys(2015) lcInsertLast = sys(2015) lnHandle=SQLStringConnect('DRIVER=SQL Server;SERVER=server;DATABASE=Northwind;UID=sa;PWD=*******') lcTemp = 'T'+sys(2015) create table (lcTemp) free (FileHolder m nocptrans) append blank append memo FileHolder from (getfile()) use hin=fopen(lcTemp+'.dbf',12) fseek(hin,43) fwrite(hin,'G',1) fclose(hin) use (lcTemp) alias 'temp' SQLEXEC(lnHandle, ; "insert into northwind.dbo.employees "+; "(LastName,FirstName,Title,Photo)"+; " values "+; "('"+lcInsertLast+"','"+lcInsertFirst+"','Sales representative',?temp.FileHolder)") use in 'temp' erase (lcTemp+'.*') *!* another way: *!* lcFile=GetFile() *!* handle=fopen(lcFile) *!* lnSize=fseek(handle,0,2) *!* fseek(handle,0,0) *!* lcContent=fread(handle,lnSize) *!* fclose(handle) *!* SQLEXEC(lnHandle, ; *!* "insert into northwind.dbo.employees "+; *!* "(LastName,FirstName,Title,Photo)"+; *!* " values "+; *!* "('"+lcInsertLast+"','"+lcInsertFirst+"','Sales representative',0x)") && Insert test data *!* SQLExec(lnHandle,; *!* [EXEC sp_dboption 'northwind', 'select into/bulkcopy', 'true';]+; *!* [DECLARE @ptrval binary(16);]+; *!* [SELECT @ptrval = TEXTPTR(photo) ]+; *!* [FROM employees ]+; *!* [WHERE LastName = ']+lcInsertLast+[' and FirstName =']+lcInsertFirst+[';]+; *!* [UPDATETEXT employees.photo @ptrval 0 NULL ?lcContent ;]+; *!* [EXEC sp_dboption 'northwind', 'select into/bulkcopy', 'false']) * READ part lcOutFileName = "c:\testfile.out" SQLEXEC(lnHandle,; "select * from northwind.dbo.employees "+; [WHERE LastName = ']+lcInsertLast+[' and FirstName =']+lcInsertFirst+['],; 'mySQLData') && Read from SQL server SQLDisconnect(lnHandle) * Extract data from fpt select mySQLData lcTemp = 'T'+sys(2015) copy fields Photo to (lcTemp) next 1 use in 'mySQLData' Hin = fopen(lcTemp+".fpt") hout=fcreate(lcOutFileName) lnSize=fseek(hin,0,2) fseek(hin,0x204,0) && Move file pointer to offset 0x204 where file size is stored lnSize = 0 for ix=4 to 1 step -1 lnSize=lnSize+asc(fread(hin,1))*256^(ix-1) endfor fwrite(hout,fread(hin,lnSize),lnSize) =fclose(hin) and fclose(hout) erase (lcTemp+'.*')