Sqlreporting

Since this got reverted I though I'd just create a new pull request rather than reverting the revert.