Fixing SQL bug in queue record