SUM integer values can exceed int even when each row fits. Cast each input to bigint before aggregation and keep NULL and empty-set behavior visible.
SQL SERVER – LEN and DATALENGTH of NULL Simple Example
A common mistake is checking LEN(@var) = 0 for a NULL value. LEN and DATALENGTH of NULL both return NULL, not zero, as this simple example shows.
SQL SERVER – 2005 T-SQL Paging Query Technique Comparison (OVER and ROW_NUMBER()) – CTE vs. Derived Table
Paging in SQL Server 2005 with ROW_NUMBER: CTE vs. derived table. I compare both methods and show they give the same performance for common queries.
SQL SERVER – Retrieve – Select Only Date Part From DateTime – Best Practice
Selecting the date part and formatting it are different tasks. I keep typed dates for calculations and text for display.
SQL SERVER – UDF – Function to Display Current Week Date and Day – Weekly Calendar
A script and UDF that show each current week date with its day, from Sunday to Saturday, using DATEPART and DATEADD. Handy for a weekly calendar report.
geometry SRID Mismatch: NULL Is Not a Zero Distance
geometry SRID mismatch is different from coincident points. Keep both identifiers beside the distance and preserve the distinction between NULL and zero.
SQL SERVER – User Defined Functions (UDF) Limitations
Why are stored procedures more flexible? Here are the User Defined Functions (UDF) limitations: fewer input parameters, no GETDATE(), one result set, and more.







