How to Reference JSON Keys that Contain Special Characters when using OPENJSON, JSON_QUERY, and JSON_VALUE (SQL Server)

If you’re using a T-SQL function such as OPENJSON(), JSON_QUERY(), or JSON_VALUE(), you might be wary of any non-alphanumeric characters that might be in the JSON document that you’re working with. Especially if those special characters are in the key names, and you need to reference those key names.

Continue reading

How to Merge Documents when Importing a File into MongoDB

When you use mongoimport to import files into MongoDB, you have the option of merging existing documents with the ones that you’re importing.

In this case, if an imported document has the same _id value as an existing one in the collection that you’re importing into, the existing document will be merged with the one being imported.

You can also specify another field (other than the _id field) to be the matching field if required.

Continue reading

How to Replace Existing Documents when Importing a File into MongoDB

When you use mongoimport to import files into MongoDB, you have the option of replacing existing documents that match the ones you’re importing.

By this I mean, if an imported document has the same _id value as an existing one in the collection you’re importing into, the existing document will be replaced with the one being imported.

You can also specify another field (other than the _id field) to be the matching field if required.

The way to replace existing documents when using mongoimport is to use upsert mode.

Continue reading

How to Import a JSON File into a SQL Server Table

If you have a JSON document, there are several ways you could go about getting it into SQL Server.

If it’s a small document, you could copy and paste its contents. If it’s a larger document (or even a small one), you might want to import the whole file.

This article presents an example of importing a JSON file into a SQL Server database.

Continue reading