![]() The default increment for a new sequence object is 1. ![]() If the increment is a negative value, the sequence object is descending otherwise, it is ascending. Value used to increment (or decrement if negative) the value of the sequence object for each call to the NEXT VALUE FOR function. The default start value for a new sequence object is the minimum value for an ascending sequence object and the maximum value for a descending sequence object. The START value must be a value less than or equal to the maximum and greater than or equal to the minimum value of the sequence object. The first value returned by the sequence object. If no data type is provided, the bigint data type is used as the default. Any user-defined data type (alias type) that is based on one of the allowed types.[ built_in_integer_type | user-defined_integer_typeĪ sequence can be defined as any integer type. Specifies the unique name by which the sequence is known in the database. To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation. Transact-SQL Syntax Conventions Syntax CREATE SEQUENCE sequence_name Use sp_sequence_get_range to get multiple sequence numbers at once.įor information and scenarios that use both CREATE SEQUENCE and the NEXT VALUE FOR function, see Sequence Numbers. Unlike identity columns values that are generated when rows are inserted, an application can obtain the next sequence number without inserting the row by calling the NEXT VALUE FOR function. User applications can reference a sequence object and coordinate the values across multiple rows and tables. ![]() The relationship between sequences and tables is controlled by the application. Applications refer to a sequence object to retrieve its next value. Sequences, unlike identity columns, are not associated with specific tables. 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. 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. Applies to: SQL Server (all supported versions) Azure SQL DatabaseĬreates a sequence object and specifies its properties. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |