A friend asked for a UDF that returns only the first word of a sentence. Here is my script with CHARINDEX and SUBSTRING, and how to turn it into a function.
Negative Identity Seed and Negative Increment in SQL Server
A Negative Identity seed lets a column start below zero, and a negative increment makes it count down. This post tests IDENTITY(-1,-1) and IDENTITY(-2147483648,1) on SQL Server 2025, shows gaps after a rollback, DBCC CHECKIDENT, and what to do when an int identity runs out. It also shows SEQUENCE as the flexible alternative.
CROSS APPLY Aggregate: An Empty Input Can Still Return a Row
CROSS APPLY aggregate behavior depends on whether the right-side query actually produces a row. I inspect that query before assuming unmatched customers disappear. An aggregate without GROUP BY can return a row even when its input is empty.
Finding the Nearest Store With the geography Type
Find the nearest store with SQL Server geography, validate coordinate order, apply a distance radius, and inspect spatial index use.
SQL SERVER – Finding the Occurrence of Character in String
A quick T-SQL method using LEN and REPLACE to count the occurrence of character or word in a string, written as a hint for TSQL Beginners Challenge 14.
Synchronizing Data Between Two Databases
Synchronizing data between two SQL Server databases requires a latency target, change source, conflict rule, and recovery plan before tool selection.
geometry MakeValid: Repair Can Change the Geometry Type
geometry MakeValid returns a valid geometry from an invalid instance, but the result can change type. I keep the original beside the proposed repair. A validity flag alone does not describe everything that changed.
SQL SERVER – Computed Column and Performance – Part 3
Part 3 of my series on computed column and performance shows how an index improves the performance of a computed column. Read the earlier parts first.
SQL SERVER – SHRINKDATABASE For Every Database in the SQL Server
A query tuning visit turned into a lesson on why running SHRINKDATABASE for every database is a bad idea. Here is what happened at the client’s office.
Random Tokens in SQL Server: Generation, Storage and Expiry Checks
Random tokens in SQL Server need more than a generated value. Their stored state must define expiry, revocation and whether consumption already occurred. A guarded disposable fixture makes the boundary conditions explicit.










