&& Connect to the server nn = SQLStringConnect("Driver=SQL Server;Server=XXXXXX;Database=XXXXX;UID=XXXXX;"+; "PWD=XXXXXX;") && Change the FetchAsNeeded option default value CursorSetProp("FetchAsNeeded",.T.,0) && Updated based on the thread FetchAsNeeded SPT blocking remote views? Thread #1145681 Message #1145743 CURSORSETPROP("AllowSimultaneousFetch",.T.,0) CursorSetProp("FetchSize",300,0) && FetchAsNeeded option requires asynchronous connection for SPT cursors SQLSetProp(nn,"Asynchronous",.T.) do while NOT USED("MyResult") && SQLEXEC() will return 0 till all records && fetched and returned to client. So, && when you want to fetch, just wait till alias created with && first FetchSize number of records (300 in this sample) =SQLExec(nn,"SELECT * FROM TEST","MyResult") enddo * return the default option value to .F. CursorSetProp("FetchAsNeeded",.F.,0)
&& initial number of records equals to FetchSize lnRecordsInterval = CursorGetProp("FetchSize","MyResult") lnRecordsTotal = m.lnRecordsInterval WAIT WINDOW "Records: " + str(m.lnRecordsTotal) NOWAIT NOCLEAR && loop till all records are downloaded do while SQLExec(nn) = 0 && get next FetchSize records m.lnRecordsTotal = m.lnRecordsTotal + m.lnRecordsInterval WAIT WINDOW "Records: " + str(m.lnRecordsTotal) NOWAIT NOCLEAR enddo && show exact final number of records WAIT WINDOW "Records: " + str(reccount) + " (finished)" TIMEOUT 3