Brett,
Thanks for your reply, I'll try out your script tomorrow morning when I get into the office. And let you know the result.
The reason I'm confused, is I set up my script using osql and it worked fine on our test server, It didn't run at all on production, then I found that it did run if I changed osql to isql, but with the quirk noted. I'm sure it is something to do with the OLE DB config, but I am not sure where to start looking for differences. Also the osql version might work if I could get ODBC set up on production, but I'm not sure how to go about doing that.
Anyway, thanks again for all your help and I'd be grateful for any further suggestions.