NOLOCK Hint in SQL Queries: Myths, Misconceptions, and Best Practices In the world of SQL Server, the NOLOCK hint often generates spirited debates among database professionals. This hint is frequently used but equally misunderstood. In this blog post, we’ll explore what the NOLOCK hint does, dispel some common myths and misconceptions, and provide best practices for its use. Understanding the NOLOCK Hint The NOLOCK hint allows SQL Server to perform a dirty read, which means it can read data that …

SQL Server WITH NOLOCK Read more »

Why are there so many backup messages in my sql server logs? SQL Server logs contain a wealth of information about the server’s operation, including details about backup operations. This data can be quite helpful for various administrative tasks like troubleshooting, audit, performance tuning, or recovery. The reason why you see many backup messages in your SQL Server logs is because every time a backup or restore operation occurs, an entry is made in the SQL Server error log and …

SQL Server Logs – flooded with backup messages Read more »

When working with data in SQL Server, there may be times when you need to remove leading zeros from a string. This task can be particularly common when dealing with numerical data stored as strings, such as ZIP codes, product codes, or other formatted numbers. In this blog post, we’ll explore several methods to remove leading zeros in SQL Server. Method 1: Using CAST and CONVERT Functions One straightforward way to remove leading zeros is to convert the string to …

Leading Zeros in SQL Server Read more »

Shrinking a database can seem like a helpful way to save space and resources, particularly if a database has grown substantially over time. However, SQL Server’s default maintenance plans that include database shrinking can lead to several performance issues. Here’s why: Fragmentation: When a database is shrunk, the data pages are reorganized to create a contiguous block of free space at the end of the data file, which can cause severe fragmentation. This fragmentation can significantly degrade the performance of …

Database Health Quickscan – Default maintenance plans to shrink database – Ouch Read more »

Welcome to July – a month that signifies a shift in focus to the unseen heroes of our digital infrastructure – our databases. As the founder of Database Health and Stedman Solutions, it is with great pleasure that I announce this month as Database Health Monitor Month! This annual event allows us to appreciate our precious data, explore the intricacies of our systems, and focus on enhancing the health of our databases. This July, let’s not merely keep our databases …

Celebrating Database Health Monitor Month Read more »

One of the fundamental aspects of working with SQL Server is understanding how to get the number of rows affected by a query. Whether you’re working with SELECT, INSERT, UPDATE, or DELETE statements, knowing the row count can provide critical insights into your database operations. In this blog post, we’ll explore different methods to retrieve the row count in SQL Server and discuss scenarios where each method is most effective. 1. Using COUNT(*) with SELECT Statements When you need to …

How to count rows in SQL Server Read more »

Exploring Example SQL Databases in SQL Server SQL Server is a robust relational database management system that offers a variety of features for data management, analysis, and reporting. One of the great resources for learning and testing SQL Server capabilities is the set of sample databases provided by Microsoft. These databases are rich with sample data and scenarios, making them ideal for education, training, and demonstration purposes. In this post, we’ll dive into five popular sample databases: AdventureWorks, Contoso, Northwind, …

Example SQL Server Databases Read more »

July is here and that means it’s time for us to pivot our collective gaze to the pulse of our digital lifeblood – our databases! As the founder of Database Health and Stedman Solutions, I am excited to declare this month as Database Health Monitor Month! This is our annual opportunity to appreciate the often-unseen guardians of our valuable data, and to dive deeper into the heartbeat of our systems, replete with intricate data structures and complex relations. It’s time …

Sneak preview – July is Database Health Monitor Month Read more »

Over the years developing Database Health Monitor I have added a number of keyboard shortcuts to make life easier when working in the application. Some of these are listed here to share since they are not all completely obvious. Backspace Key – Jump to the last report viewed The Backspace key can be used to jump to the previous report that you were viewing. Not just that, but hit it multiple times and you can browse back through the history …

Keyboard Shortcuts for Database Health Monitor Read more »

Parameter Sniffing and Conditional Logic in SQL Server Stored Procedures: A Performance Pitfall Parameter sniffing is a well-known feature in SQL Server that can significantly impact query performance. While it often leads to optimized query execution, it can sometimes cause performance issues, especially when combined with conditional logic in stored procedures. In this article, we’ll explore how parameter sniffing interacts with conditional logic and how this interaction can lead to suboptimal performance. Understanding Parameter Sniffing Parameter sniffing occurs when SQL …

Parameter Sniffing and Conditional Logic in SQL Server Stored Procedures Read more »