Skip to content
Home » TSQL

TSQL

Incremental Integrity Check for Large Databases

Traditional database integrity checks in SQL Server can be time-consuming and resource-intensive, especially for large databases, even when using super cool tools like Ola Hallengren’s maintenance solution.

To address this challenge, I developed a TSQL script for performing incremental integrity checks, which significantly optimizes the process and reduces its impact on the server.

Read More »Incremental Integrity Check for Large Databases

SQL Server Index Mastery: Choosing the Right Column Order

It’s been a while since my last post about SQL Server performance optimization. This one focuses on index design and how the order of columns in your indexes can make or break your database queries. Using my insights from real-world consulting experience, this guide should help you understand the critical decisions that would impact your database performance.

How does SQL Server decide where to look first when executing a query? The answer lies in the structure of your indexes. Learn how the sequence of key columns can optimize your data retrieval, making your database faster and more responsive.

Read More »SQL Server Index Mastery: Choosing the Right Column Order

Understanding ‘ALTER TABLE SWITCH statement failed’ errors 4907, 4908, and 4912

Recently we’ve encountered an interesting use case for a customer.

They had a table with partitioning that they needed to be archived (with the help of said partitioning), but the ALTER TABLE SWITCH commands were failing with a peculiar error:

Error 4907, ‘ALTER TABLE SWITCH’ statement failed. The table ‘MyDB.dbo.PrtTable1’ has 4 partitions while index ‘IX1’ has 6 partitions.

This prompted some insightful research into some of the validations done by SQL Server behind the scenes when executing an ALTER TABLE SWITCH command.

Read More »Understanding ‘ALTER TABLE SWITCH statement failed’ errors 4907, 4908, and 4912

Solving the Latch Convoy Problem with OPTIMIZE_FOR_SEQUENTIAL_KEY in SQL Server 2019

Have you ever come across an elusive SQL Server issue known as the “Latch Convoy Problem” or “Last Page Insert Contention”? It’s a rare and challenging problem to encounter in real-world scenarios. In fact, it’s so uncommon that many database professionals may go their entire careers without experiencing it firsthand. But sometimes, the unexpected happens, and you find yourself face to face with this elusive beast.

Resolved: Login failed for user NT AUTHORITY\ANONYMOUS LOGON – Delegation Step-by-Step

Sometimes when trying to access a linked server, you’d get an error saying “Login failed for user NT AUTHORITY\ANONYMOUS LOGON”. This happens because you’re connected using Windows authentication, and SQL Server fails to “forward” your credentials to the linked server.

Hopefully, with this blog post, I’ll provide you with an easy-to-understand step-by-step guide, which would help you resolve the issue the right way, without any workarounds.

Read More »Resolved: Login failed for user NT AUTHORITY\ANONYMOUS LOGON – Delegation Step-by-Step