Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi ,

I am inserting a value into identity column but am not able to do that..Kindly help to insert value into identity column of table..

What I have tried:

set identity_insert meghr on
insert into meghr select '1'
set identity_insert meghr off

error like in below

Msg 8101, Level 16, State 1, Line 2
An explicit value for the identity column in table 'meghr' can only be specified when a column list is used and IDENTITY_INSERT is ON.
Posted
Updated 18-Apr-16 21:03pm
Comments
Tomas Takac 18-Apr-16 2:27am    
Where exactly are you stuck? The error message seems pretty clear to me.
Karthik_Mahalingam 18-Apr-16 2:54am    
your insert statement seems wrong.

You have to type column name:
SQL
set identity_insert meghr on
insert into meghr (nos) VALUES (1)
set identity_insert meghr off
 
Share this answer
 
The meaning of an Identity column is that a database sets the value, not your insert. If you really need to set it yourself:
THIS[^] will help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900