Hi,
I want to insert record in database and I am able to insert using insert query, but the problem is that I am unable to insert data in Identity column.
Here is the Query which I am writing
INSERT into tblLogin ([ID], [FirstName], [LastName], [Password) VALUES (15, N'abc', N'xyz', N'pass')
Please tell me what is wrong in the query?
Thanks in advance.
Shankar M
10-Feb-2013Amit Singh
12-Nov-2010Your query is correct, but the problem is that you can not insert data directly into Identity column.
All you have to do is to set Identity insert of that column on, and after you are done just set it off.
Here is the script that will do what you want.
SETIDENTITY_INSERT tblLogin ON
INSERTinto tblLogin([ID], [FirstName], [LastName], [Password])VALUES (15,N'abc',N'xyz',N'pass')
SETIDENTITY_INSERT tblLogin OFF