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
 Transact-SQL (2000)
 Cannot insert duplicate key row

Author  Topic 

Sprinjee
Starting Member

42 Posts

Posted - 2005-08-31 : 08:52:44
I need to update some of the values in col1 table1 with the values in col2 table2. When I try to do this in this way:

update table1 set col1 = t2.col2 from table 2 t2
inner join table1 on id = t2.id

Server: Msg 2601, Level 14, State 3, Line 1
Cannot insert duplicate key row in object 'table1' with unique index 'table1'.
The statement has been terminated.

The query works fine on other tables. Is there a way to rewrite it...since: update table1 set col1 = (select col2 from table2 where id = 1) does work

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-31 : 09:00:11
I think col1 is defined as Unique so that you cannot update it with the value already assigned
Post table structures

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -