A sequence is a user-defined schema bound object that generates a sequence of numeric values according to the specification with which the sequence was created. The sequence of numeric values is generated in an ascending or descending order at a defined interval and can be configured to restart (cycle) when exhausted. Sequence supports TINYINT, INT, SMALLINT, BIGINT, DECIMAL and NUMERIC data types.
Sequences, unlike identity columns, are not associated with specific tables. The relationship between sequences and tables is controlled by the application. User applications can reference a sequence object and coordinate the values across multiple rows and tables.
Create Sequence in following steps:
1. Under Selected DB -> Go to Programmability -> then right click on Sequences and Select New
2. You can check supported Data types on New Sequence Screen.
3. Create New Sequence by providing your values.
4. And you are done, you can also create the same Sequence through Query as:
CREATE SEQUENCE [dbo].[TestSequence]
AS [int]
START WITH 1
INCREMENT BY 2
MINVALUE 1
MAXVALUE 50
CACHE
GO
|
Comments
Post a Comment