You have a Employe table with EmpId, EmpName, EmpAge. There are 5 records as of now. EmpId is a primary key with identity column. Now the identity value is 5. You need to start the identity value from 10 instead of 6. Write the query for that?

 Posted by Nagasundar_Tn on 12/3/2012 | Category: Sql Server Interview questions | Views: 3094 | Points: 40

We need to add identity column value explicitly. For that we can use the following query:

Set identity_insert EmployeMaster on 

Insert into EmployeMaster(EmpId, EmpName, EmpAge)
values (10,'Shankar',19)

In the above query I mentioned "Identity_Insert on" for table name EmployeeMaster. Second I specified all the column names and inserted the values corresponding to tht column. Now we will be having identity value as 10.

Asked In: GAVS Technology | Alert Moderator 

Comments or Responses

Login to post response