Added an SQL utility function