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

How to Insert JSON into a Table in SQL Server

If you have a JSON document that you need to insert into a table in a SQL Server database, the OPENJSON() function could be just what you need.

OPENJSON() is a table-valued function that returns JSON in tabular format. That is, it converts your JSON into a tabular result set consisting of rows and columns. Therefore, it enables you to insert it into a table.

Continue reading