Friday, August 2, 2019

Identity in SQL

What is Identity in Sql:



An identity column of a table is a column whose value increases automatically. The value in an identity column is crated by the server. A user generally cannot insert a value into an identity column.


Example:

  1. CREATE TABLE EMPLOYEE  
  2. (  
  3.    IID INT IDENTITY(1,1),  
  4.    NAME [varchar](MAXNOT NULL,  
  5.    AGE INT NOT NULL  
  6. )  



IDENTITY_INSERT ON allows a user to insert data into an Identity column and IDENTITY_INSERT OFF restricts a user from inserting data into an Identity column.

No comments:

Post a Comment

How to use SQL pagination using LIMIT and OFFSET

  How to extract just a portion of a larger result set from a SQL SELECT. LIMIT n is an alternative syntax to the FETCH FIRST n ROWS ONLY. T...