Medium severitysql
Power BI Refresh Error:
Sequence Value Error
What does this error mean?
A Snowflake sequence produced an unexpected value or the sequence object was not found. Common causes include using a sequence in a context that does not support it, or referencing a dropped sequence.
Common causes
- 1The sequence referenced in a DEFAULT or INSERT statement was dropped or renamed
- 2A NEXTVAL expression was used in a context where it is not supported (e.g., in a WHERE clause, GROUP BY, or as a join key)
- 3The sequence ran out of values (reached the maximum value with NO CYCLE configured)
- 4A sequence was used in a multi-row INSERT but the rows did not each get a unique value due to batching behavior
- 5The sequence start/increment values produce gaps that violate a downstream uniqueness expectation
How to fix it
- 1Verify the sequence exists: `SHOW SEQUENCES IN SCHEMA <schema>`.
- 2If the sequence was dropped, recreate it with `CREATE SEQUENCE <name> START = <current_max + 1>` to avoid collisions with existing values.
- 3If the sequence reached its maximum: `ALTER SEQUENCE <name> RESTART WITH <new_start>`.
- 4For gaps: note that Snowflake sequences are not strictly sequential across concurrent sessions — they guarantee uniqueness, not contiguity. Use `ROW_NUMBER()` if contiguous values are required.
- 5Do not use NEXTVAL in contexts like WHERE or GROUP BY — use it only in INSERT or SELECT output expressions.