Have you faced this? Assume that you have created a Sequence object for generating values sequentially for tables which data type is set as int, and suddenly it shows the next number as -2147483648.
See below code;
- -- creating sequence
- CREATE SEQUENCE [dbo].[OrderSequence]
- AS int
- START WITH 1
- INCREMENT BY 1
- MAXVALUE 2
- CYCLE
- GO
- -- requesting numbers three times
- SELECT (NEXT VALUE FOR dbo.OrderSequence) AS OrderSequence
- GO 3
What could be the reason? If you analyze the code written above, you can easily find the issue. I have not used MINVALUE property when creating the Sequence, hence it takes the lowest value of the data type set for the Sequence, which is -2147483648 for int data type. You may experience the same, if so, check and see whether the MINVALUE has been set or not.
No comments:
Post a Comment