Fixed Sql functions.