Format a date with CONVERT, then use its alias in ORDER BY, and the rows come back in a different order. Here is a simple example of this formatted date surprise.
Inline Table-Valued Functions: Parameterized Views That Stay Fast
Compare inline table-valued functions with scalar functions, preserve customer results, and inspect plans before claiming performance gains.
SQL SERVER – Simple Method to Find FIRST and LAST Day of Current Date
I calculate the FIRST and LAST Day of Current Date using explicit date boundaries. The historical sample starts on October 28, 2017.
Which is Optimal – TOP 0 OR WHERE 1 = 2? – Interview Question of the Week #190
Which is optimal, TOP 0 or WHERE 1 = 2? Many interview answers get this wrong, but they are both the same, and STATISTICS IO shows why.
Alphabets – SQL SERVER – Retrieving Rows With All Alphabets From Alphanumeric Data
I got an email from one of my blog readers asking for an easy way to identify if a given string contains only alphabets. There can be methods.
SQL SERVER – UDF – User Defined Function to Extract Only Numbers From String – Number Table Method
I rewrote my User Defined Function to extract only numbers from a string. The new one uses a numbers table, also called a Tally table, instead of a WHILE loop.
SELECT COUNT Without FROM Returns 1, Not an Error
A SELECT COUNT without FROM does not fail in T-SQL. It returns 1, because the table name after COUNT(*) becomes a column alias. This post shows the typo, the other silent mistakes that work the same way, and the habits that make them fail loudly.






