Well, if you happen to be using Sql Server you can do that sort of thing in T-Sql. In Oracle, you can also accomplish the same thing using pl/sql. Either way i'd do it in a stored ...
Don't be afraid of using your chosen database's command-line client. I might as well say this up front: I don't like using GUI (aka non-command-line or graphical) tools with my databases. This is ...