local lnKount, lcSQL, lcList, lcValues, lnI, laFields[1] lnKount = afields(laFields, 'crsMyCursor') lcSQL = [] lcList = [(] lcValues = [(] for lnI = 1 to lnKount lcList = lcList + laFields[lnI, 1] lcValues = lcValues + [?crsMyCursor.] + laFields[lnI, 1] if lnI < lnKount lcList = lcList + [, ] lcValues = lcValues + [, ] endif endfor lcList = lcList + [)] lcValues = lcValues + [)] lcSQL = [insert into MySQLTable ] + lcList + [ VALUES ] + lcValues *!* all code above here can be rolled into a class method where you can pass *!* either the cursor name of an array of fields to generate the code for you. *!* you can do the same for update sql as well. (i.e., make it generic and reusable) *!* the sql code only needs to be generated ONCE. select crsMyCursor scan lnReturn = sqlexec(nHandle, lcSQL) if lnReturn < 0 *!* handle failure here endif endscan