Top "Upsert" questions

For issues relating to performing upsert (combination update/insert) operations.

MERGE Violation of PRIMARY KEY constraint

I have a SQL Server 2008 many-to-many relationship table (Assets) with two columns: AssetId (PK, FK, uniqueidentifier, not null) AssetCategoryId (PK, …

sql sql-server sql-server-2008 tsql upsert
Mongodb upsert throwing DuplicateKeyException

I do get this error [2] from time to time when attempting to upsert (increment or insert) a document using method [1]. [1] …

spring mongodb upsert
How to upsert multiple rows in PostgreSQL

I'm trying to write a query like this in PostgreSQL 9.5.2: INSERT INTO a (id, x) SELECT id, x FROM b …

postgresql upsert postgresql-9.5
Upsert in Postgres using node.js

I'm trying to do an insert or update in a postgres database using node.js with pg extension (version 0.5.4). So …

postgresql node.js upsert pg
How do I reference a unique index that uses a function in ON CONFLICT?

I'm using postgres 9.5.3, and I have a table like this: CREATE TABLE packages ( id SERIAL PRIMARY KEY, name VARCHAR NOT …

postgresql upsert
MS SQL equivalent of ON DUPLICATE KEY UPDATE / UPSERT

I'm a postgres user that's new to MS SQL. I need to replicate ON DUPLICATE KEY UPDATE functionality (sometimes called …

sql sql-server upsert on-duplicate-key