Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

Answers


In SQL Server, both IDENTITY property and the SEQUENCE object are used to generate a sequence of numeric values in an ascending order.

Following are some differences between identity property and the sequence object,

  • The value for the IDENTITY property cannot be reset to its initial value. In contrast, the value for the SEQUENCE object can be reset.
  • The IDENTITY property is tied to specific table and cannot be shared among multiple tables since it is a table column property, but the SEQUENCE object is defined by the user and can be shared by multiple tables since is it is not tied to any table.
  • To generate the next IDENTITY value, a new row must be inserted into the table. On the other hand, the next VALUE for a SEQUENCE object can simply be generated using the NEXT VALUE FOR clause with the sequence object.
  • A maximum value cannot be set for the IDENTITY property. On the other hand, the maximum value for a SEQUENCE object can be defined. 
For more details, code samples use this referance 

Share your answer


Share as a guest

Please subscribe me to the CodeChef4U.

By creating your new answer, you agree to the privacy policy and terms of service.