Handle duplicate key errors 2627 and 2601 in TRY CATCH, preserve unexpected errors, and avoid racing existence checks during inserts.
OS Thread of a Session: Map Session ID to Windows Thread ID
To find the OS thread of a session, join sys.dm_os_tasks to sys.dm_os_threads on the worker address. This post reads the map for your own session and for every user session. It explains why idle sessions have no row, why parallel queries have several, and how to follow a thread in Performance Monitor.
JDBC and sendStringParametersAsUnicode: The Hidden Index Scan
Diagnose sendStringParametersAsUnicode conversions, align JDBC parameters with varchar indexes, and preserve required Unicode data.
SQL Puzzle – SELECT ~ 1 : Guess the Answer
SELECT ~ 1 returns -2 because the tilde is the bitwise NOT operator and flips all 32 bits of an int. This post keeps the puzzle, tests the answer on SQL Server 2025 with five data types and shows where the tilde is useful.
NOT IN With a NULL in the List Returns No Rows
See why NOT IN with a NULL returns no customers, then compare five sample rows, NOT EXISTS, an IS NOT NULL filter, and query plans.
USE HINT: Switching Off One Optimizer Rule Without Trace Flags
Apply USE HINT to one query, inspect supported names, compare optimizer behavior, and manage Query Store hints with a clear removal plan.
When Did SQL Server Last Restart? Four Ways to Check
Find SQL Server’s last restart using startup metadata, tempdb, logs, and sessions, then interpret reset counters correctly.







