Generates sql query to add a range of days into a table