Hello, I think this is a simple query but it is being a long time I haven't write queries. If you can help me I will appreciate it a lot.
I need to copy some data from one table to another table. This is the statement I am trying to use:
insert into ItemDetail(ItemMasterId,Content,ItemMasterAttributeId)
Select distinct itemid,Qty,Itemattributeid from #tempitemdetail
and Im getting the following error:
Msg 2627, Level 14, State 1, Line 86
Violation of PRIMARY KEY constraint 'PK_ItemDetail'. Cannot insert duplicate key in object 'dbo.ItemDetail'. The duplicate key value is (11171, 18).
The statement has been terminated.
The table Itemdetail has a lot of attributes for same Itemid. I just need to add a new value for a new attribute id.
Could you help me to figure it out how to write my query to work? Thanks