Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 error doing an insert from one table into another

Author  Topic 

itsonlyme4
Posting Yak Master

109 Posts

Posted - 2008-01-15 : 14:42:10

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?

itsonlyme4
Posting Yak Master

109 Posts

Posted - 2008-01-15 : 14:49:11
is it safe to temporarily set

SET IDENTITY_INSERT mytable ON
Go to Top of Page

itsonlyme4
Posting Yak Master

109 Posts

Posted - 2008-01-15 : 15:42:47
I referred to BOL "SET IDENTITY_INSERT my table ON"
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-01-15 : 23:39:21
You have to unless take out identity from target table or don't copy values of that column.
Go to Top of Page
   

- Advertisement -