To convert empty string to NULL in a date column, wrap the text in NULLIF before you cast it. A plain CAST returns 1900-01-01 and hides the problem. This post tests five expressions on six text values, including a real 1900 date, a run of spaces and a tab, and shows which ones stay correct.
Simple Interest in SQL Server: A Function That Keeps Cents
Simple interest in SQL Server is principal times rate times years divided by 100, and a T-SQL function returns it in one line. This post shows how an int return type drops the cents and what SCHEMABINDING changes. It measures the cost of a scalar function on 500,000 rows and ends with compound interest.
AT TIME ZONE Twice: Convert UTC to Local Time in SQL Server
AT TIME ZONE twice converts UTC to local time in SQL Server. The first use labels a plain value as UTC and the second converts it. A demo shows the common one step mistake, stores in three cities, and the missing and repeated hours of daylight saving.
Running Totals That Reset Every Month
Calculate running totals that reset by calendar month, customer, or fiscal period, using stable ordering and explicit ROWS frames.
LTRIM and RTRIM With Custom Characters in SQL Server 2022
Use LTRIM and RTRIM with custom characters in SQL Server 2022, understand character sets, test TRIM directions, and preserve valid text.
Quartiles With PERCENTILE_CONT and NTILE
Compare quartiles from PERCENTILE_CONT with NTILE row buckets, calculate interquartile range, and flag candidates beyond 1.5 IQR.
Convert Integer to Date in SQL Server: ddMMyyyy Values
To convert integer to date values such as 09122020, split the number into day, month and year and build the date from the parts. This post compares four methods on tested data, shows why a lost leading zero and the session language break two of them, and times them on a million rows.







