Here’s how to install MariaDB on a Mac via the Homebrew package manager.
Continue readingTag: how to
3 Ways to Remove a Value from an Array in MongoDB
MongoDB provides a few operators that enable you to remove values from arrays.
These include:
$pull
$pullAll
$pop
2 Ways to Append a Value to an Array in MongoDB
If you have a collection of documents in MongoDB that contain arrays, you can add new values to those arrays if required.
Depending on your specific requirements, you can use the $push
operator or the $addToSet
operator.
Return the Partition Number for Each Row When Querying a Partitioned Table in SQL Server (T-SQL)
If you’ve got a partitioned table in SQL Server, and you now want to run a query that includes the partition number on each row returned by the query, you can use the $PARTITION
system function to do just that.
The $PARTITION
function returns the partition number into which a set of partitioning column values would be mapped for any specified partition function.
You can therefore use it in your SELECT
statement to return the partition that each row belongs to.
How to Edit Linked Server Options using T-SQL
If you’ve previously created a linked server, but you now want to update one or more of its server options, you can do that either via the SQL Server Management Studio GUI or with T-SQL.
If you choose to do it with T-SQL, the sp_serveroption
system stored procedure is what you need.
Get the Short Day Name in SQL Server (T-SQL)
In SQL Server, you can use the FORMAT()
function to return the short day name from a date. FORMAT()
is a T-SQL function that enables you to format dates and numbers to a specified format.
This function returns its result as a string. Specifically, it returns it as either a nvarchar or null as the case may be.
Continue readingHow to Delete MongoDB Documents by Importing a File
As of mongoimport
version 100.0.0, you can delete documents in MongoDB based on an imported file. To do this, use delete
mode.
When you use delete
mode, 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 deleted.
You can also specify another field or fields (other than the _id
field) to be the matching field if required.
2 Ways to Limit the Documents Returned in MongoDB
When you run queries In MongoDB, you have the option of limiting the documents returned. This is where you specify a maximum number of documents to be returned by the operation.
For example, if an operation would normally return 2,000 documents, but you specify a limit of 1,000, then only 1,000 documents are returned. However, if the operation would only return say, 500 documents, then all 500 are returned (because they don’t breach the 1,000 document limit).
This is a bit like using the TOP
clause in SQL Server, or the LIMIT
clause in MySQL, MariaDB, PostgreSQL, and SQLite.
How to fix “Server is not configured for RPC” Msg 7411 using T-SQL
If you’ve encountered error Msg 7411, Level 16 in SQL Server, it’s because you need to enable “RPC out” on the linked server that you’re trying to execute code on.
Continue reading4 Ways to Delete a Document in MongoDB
In MongoDB, if you need to delete a document in the mongo shell, you can use:
- The
db.collection.remove()
method - The
delete
command - The
db.collection.deleteOne()
method - The
db.collection.deleteMany()
method
This article provides examples of each.
Continue reading