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.
Post:103
Points:721Re: How to insert data in Identity Column?
Hi Haider,
Your 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.
SET IDENTITY_INSERT tblLogin ON
INSERT into tblLogin ([ID], [FirstName], [LastName], [Password]) VALUES (15, N'abc', N'xyz', N'pass')
SET IDENTITY_INSERT tblLogin OFF
Hope this will help you.