FoxPro makes extra pass to determind field sizes in query based on the first record in the table. Use PADR() function for character fields to get desired field width.
...
PADR(IIF(empty(a.dtrefu),[''],['] + DTOC(a.dtrefu) + [']),10) AS DTREFU, ;
...
Also, to make code more readable when you build query dynamicaly, you can use "[]" square brackets as string delimiters.
>I'm using the following statement in SQL: (VFP 5.0, selecting from a foxpro database.)
>
< snip >
--sb--