SQL for sequence table to fix autogenerate error