MongoDB offers various methods for counting the documents in a collection or view. There are also some aggregation operators that enable you to count incoming documents from a previous aggregation pipeline stage.
Continue readingTag: how to
Find Out the Data Type of the Columns Returned in a Result Set in SQL Server
In SQL Server, there are a few ways to get metadata of the result set from a query. This includes the data type of the columns returned by a T-SQL query.
In particular, the sys.dm_exec_describe_first_result_set
system dynamic management function is a good choice for such a task.
Import Documents into MongoDB from an Array of JSON Documents
When using mongoimport
, you can use the --jsonArray
parameter to import an array of JSON documents.
Find Out if a Query uses an Index in MongoDB
In MongoDB, you can use the cursor.explain()
method or the db.collection.explain()
method to determine whether or not a query uses an index.
These methods enable you to view the query plan for the query, which includes whether or not it uses an index.
Continue readingHow to Fix “The configuration option ‘Agent XPs’ does not exist” in SQL Server (T-SQL)
If you encounter error Msg 15123, Level 16, reading “The configuration option ‘Agent XPs’ does not exist“, you were probably trying to execute EXEC SP_CONFIGURE 'Agent XPs'
while advanced options are hidden.
This error is easily fixed.
Continue reading2 Ways to Delete a Database in MongoDB
If you no longer need a database in MongoDB you can delete it.
Technically speaking, the term normally used for deleting a database is drop. To drop a database is to delete it.
In any case, below are two ways you can drop/delete a database in the mongo shell.
Continue readingHow to Prettify Exported MongoDB Documents in mongoexport
When you use mongoexport
to export documents in MongoDB, you have the option of “prettifying” them.
By this I mean, instead of the document being presented on one long line, it instead includes line breaks, indents, etc to make it easier to read.
To do this in mongoexport
, use the --pretty
parameter.
Rename a Column in SQL Server (T-SQL)
In SQL Server, you can use the sp_rename
stored procedure to rename an object, including a column.
5 Ways to Check the Size of a Collection in MongoDB
In this article I present 5 ways that you can use to check the size of a MongoDB collection when using the mongo shell.
Continue readingHow to Fix “Procedure expects parameter ‘@statement’ of type ‘ntext/nchar/nvarchar’.” Error in SQL Server
It’s quite easy to encounter error Msg 214, Level 16 when executing stored procedures such as sp_executesql
or sp_describe_first_result_set
.
Fortunately it’s easy to fix too!
The most common reason for getting this error is that you forgot to prefix your string with N
.
Therefore, to fix this issue, try prefixing your string with N
.