error restoring a deleted record from one table to another.

  • INSERT INTO Db.mytable (column1, column2, column3, id)

    SELECT column1, column2, column3, id

    FROM db.mytableNBdoc WITH (NOLOCK)

    WHERE id = 9795008

    Server: Msg 544, Level 16, State 1, Line 1

    Cannot insert explicit value for identity column in table 'nbdoc' when IDENTITY_INSERT is set to OFF.

    I don't really understand the error. can someon help?

  • You should read the "SET IDENTITY_INSERT" topic in SQL Server Books Online.

  • am I going to mess anything up in my table temporarily setting it to

    SET IDENTITY_INSERT mytable ON

  • Hello,

    Before going ahead with setting the identity insert to on and then inserting the record, make sure that there is no record available for the specific id. Based on your database design if the table has a primary key on the "id" column then it won't allow you to insert a duplicate record with the same "id" value even though you set the identity insert to on.

    Hope this helps you.

    Thanks


    Lucky

  • Yes, it helps!!!! THANK YOU!!!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply