Applescript and SQL

I’m attempting to create an application that will use the results of a SQL select statement to name files. I’ve briefly looked at Sqlite3, but as I understand that tool, it cannot access remote MS SQL databases, which I’ll need to. I wouldn’t rule out using a third-party element like MacSQL if that’s the best solution.
The statement would be very simple, something like

tell app “thisapp”
set the_name to select * from x…
save current document as the_name & someotherstuff…
end tell

Ideas anyone?

According to this Apple List thread MacSQL is your best bet:

In Tiger, there is also a tool called Database Events, but I’ve not had a lot of luck with it. It is bundled with Tiger’s core services however, so free. Finally there’s OpenBase 10 with which I have no experience at all.