SQL updated functions