ODBC guide

Create document with partition key


Inserts a new document into the container. If the container has a partition key, supply it in the PartitionKey column as a JSON array (e.g. ["user2"]). The value must match the document attribute used as the partition key. The Document column holds the full JSON body. Use the Upsert option in WITH to update if a document with the same id already exists.

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')