> The SCAN works perfectly well but it is within a loop traversing a very large table and, in the interests of achieving the highest possible speed, I was wondering whether it was possible to construct the string using a single SQL SELECT each time rather than using a SCAN hundreds of thousands of times. The '-' delimiter is not necessary - I've just been using that in testing for readability purposes.> > Any ideas would be most appreciated.> > TIA.> > Russell.

I like Borislav's second approach best - passing the var by reference is faster than by value.

I had another idea - bit of a guess though. If you do STR(MKTWPROB,8,6) in the SQL, it should be faster overall because that becomes part of a single command. If that was done by SQL Server on the backend, it would absolutely be faster to not do it in your scan.

Oh, and Vive Le Cavalier! :)

Mike YearwoodMicrosoft MVP Visual FoxPro 2008, 2009We have enough youth. We need a fountain of smart!There may be many ways to skin a cat, but there are very few right ways to do it.