ODBC guide

Upsert document (insert or update if exists)


Inserts the document or updates it if a document with the same id already exists. Use the Upsert option in WITH on INSERT to enable upsert. Handy for sync or idempotent loads where you do not want to fail on duplicate id.

INSERT INTO TestContainer (PartitionKey, Document)
VALUES(
'["user2"]', --partition key value must match its attribute from document else it will throw error. In this example container PartitionKey is /id so we used its value. For multiple key use JSON array ["val1","val2"]
'{
  "id": "user2",
  "name": "John Doe",
  "email": "jdoe@contoso.com",
  "phone": ["12345"],
  "level": "platinum"
}')
 WITH(Upsert='true')