MongoDB Aggregate Count: countDocuments(), $count and Group By Counts

MongoDB aggregate $count stage after $match with real mongosh output

Counting documents sounds like a one-liner until a report wants totals per state, per status and per date range at once. MongoDB gives you countDocuments(), estimatedDocumentCount(), the aggregate $count stage and $group, and each fits a different job. In this tutorial, I’ll cover each MongoDB aggregate count pattern on one small orders collection, with real … Read more >>

How To Convert Int to Fixed Length String in SQL Server

Sql server left join with count and where clause

While creating a function in the SQL query, I was required to convert integers into fixed-length strings in SQL Server. After multiple research studies, I found a simple and standard way of converting. In this SQL Server tutorial, you will learn how to convert int to fixed length string in SQL Server. You will understand … Read more >>

How to Use Arithmetic Operators in SQL Server

SQL Server add operator

While working on the project, I was required to perform some calculations that required me to use arithmetic operators. In SQL Server, arithmetic operations are a fundamental part of data manipulation and querying. Here, I will discuss using of arithmetic operators in SQL Server. How to Perform Arithmetic Operations in SQL Server While performing queries … Read more >>

How To Enable Filestream In SQL Server

How To Enable Filestream In SQL Server

Recently, I got a requirement to enable the file stream for my SQL server. I have analyzed and identified the approaches mentioned in this article. In this article, I will walk you through all those approaches individually. How To Enable Filestream In SQL Server Let us discuss each approach individually. Approach-1: Using SQL Server Management … Read more >>

How to Execute a Stored Procedure in SQL Server (EXEC With Parameters)

Execute stored procedure in SQL Server with EXEC, positional and named parameters

Many guides still execute stored procedures in SQL Server with bare values and no schema, like EXEC usp_OrdersByState ‘TX’, 100. It works, right up until someone adds a parameter. The safer way is EXEC plus the schema-qualified name and named parameters, so every value lands where you meant it: EXEC dbo.usp_OrdersByState @State = ‘TX’, @MinTotal … Read more >>

Delete Duplicate Rows in SQL Server

using row_number to delete duplicate rows

If you have encountered duplicate values in your table, here is a tutorial on how to delete duplicate rows in SQL Server. Duplicate values lead to insufficient database storage. I’ll explain the three methods to delete duplicate rows from a table in this SQL Server tutorial. Method 1: Find Duplicate Rows in the Table using … Read more >>

How To Check Datatype Of Column In SQL Server

How To Check Datatype Of Column In SQL Server

Checking the Datatype Of a Column in an SQL Server is a basic task for a SQL developer or an SQL DBA. In this article, let me guide you through all the approaches to do this. How To Check Datatype Of Column In SQL Server Let us discuss all the approaches individually. Approach-1 Using SQL … Read more >>

How To Backup A Table In SQL Server

How To Backup A Table In SQL Server

I recently had to back up one critical table for a major maintenance activity for my SQL server database. I have identified a few simple approaches to do this. In this article, I will walk you through all those approaches to backup a table in an SQL Server. How To Backup A Table In SQL … Read more >>