use table1 && this is your table =afields(aStru) public array aFieldnames(alen(aStru,1)) for nLoop=1 to alen(aStru,1) aFieldnames[nLoop]=aStru[nLoop,1] endfor =excludefield("usedyr") && supply field name to be excluded cFields="" for nLoop=1 to alen(aFieldnames) cFieldname=aFieldnames[nloop] if type("cFieldname")="C" cFields=cFields+cFieldname+"," endif endfor cFields=left(cFields,len(cFields)-1) select &cFields From sqlfinal release aFieldnames return function excludefield lparameter cFieldname local nPos nPos=ascan(aFieldnames,upper(cFieldname)) if nPos>0 =adel(aFieldnames,nPos) endif return