Show us what the output looks like and we can probably come up with something. In the meantime, I'd suggest that you want something like:
myvariable=`long-sql-command`
Use of awk and cut should be able to split out the data in the columns.
Without one of the redirects (at a guess, you should still redirect STDERR to the log but stop redirecting STDOUT so the calling script can capture it instead).