When using mongoimport
, you can use the --jsonArray
parameter to import an array of JSON documents.
Tag: json
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.
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.
How to Export MongoDB Query Results to a JSON File
The MongoDB Database Tools include a utility called mongoexport
that enables you to export MongoDB data to a CSV or JSON file.
One of the things you can do with this utitlity is export query results. This article shows you how to use mongoexport
to export MongoDB query results to a JSON file.
Export a MongoDB Collection to a JSON File
The MongoDB Database Tools include a utility called mongoexport
that enables you to export MongoDB data to a CSV or JSON file.
This article shows you how to use mongoexport
to export a MongoDB collection to a JSON file.
How to Select Nested JSON in SQL Server with OPENJSON
If you’re using OPENJSON()
, but you’re trying to remember how to select an inner fragment from the JSON document, read on.
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 readingHow 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.
How to Fix: JSON_VALUE Returns NULL with Long Strings (SQL Server)
If you’re using JSON_VALUE()
to return values consisting of a long string, you might find that it returns NULL
instead of the actual value.
Or, you might be getting an error.
Continue readingHow to Fix “A correlation name must be specified for the bulk rowset in the from clause.” in SQL Server
If you encounter error Msg 491, Level 16 “A correlation name must be specified for the bulk rowset in the from clause” in SQL Server, it’s probably because you’re trying to read a file without using a correlation name.
Continue reading