I am trying to update all instances of a column (ResourceTargetGuid) in a Table (TBLE_A )
based on criteria in another table (Description field in TBLE_B = 'Marketing Group')
Here is my query:
SET ResourceTargetGuid = 'BDF0A71D-A058-480A-80FB-42F3571DBCED'
FROM TBLE_A ta INNER JOIN TBLE_B ta
ON tb.guid = ta.ItemGuid
WHERE tb.Description = 'Marketing Group'
Unfortunately, the following error is generated:
Violation of PRIMARY KEY constraint 'PK_TBLE_A'. Cannot insert duplicate key in object 'dbo.TBLE_A'.
The statement has been terminated.
Is there an edit in the query that can be made to work around this issue? TBLE_A has many records and based on this error I assume the column
ResourceTargetGuid is being used as a Primary key and I am attempting to update a record whcih already contains the value BDF0A71D-A058-480A-80FB-42F3571DBCED.
Please, any detail as to what I can do here is greatly appreciated.
Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat. The purpose of this eBook is to educate the reader about ransomware attacks.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied?
You can use SQL Server Initialize from Backup…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables.
Make a table:
Update a specific column given a specific row using the UPDATE statement:
Remove a set of values using the DELETE s…