Articles → SQL SERVER → Insert Value In Identity Column In SQL Server

Insert Value In Identity Column In SQL Server






"Identity_Insert" Statement





Syntax


Set Identity_insert table_name On / Off



Example




Picture showing the design view of the table with the primary key
Click to Enlarge



Insert into TestTable 
values 
  (1, 'Test1')








Set   Identity_insert TestTable On 
Insert into TestTable (id, Name) 
values 
  (1, 'Test1')
Set Identity_insert TestTable Off




Picture showing inserting the value in the primary key column by setting Identity_insert On
Click to Enlarge



Set Identity_insert TestTable Off



Video





Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, November 8, 2017

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250