A SQL Agent job backslash at the end of a comment line can turn a one row delete into a delete of the whole table. This puzzle sets up the job, explains the cause and tests the effect in T-SQL. It ends with a safe way to write the step.
Delete Qualified Rows From Multiple Tables: A SQL Puzzle
Delete qualified rows from multiple tables with as few logical reads as you can. This puzzle gives a setup script for three small tables, the two rules for the delete and a starting script that costs 19 logical reads. Your task is to beat that number and stay correct.
SQL SERVER – Relating Unrelated Tables – A Question from Reader
A reader asked how to relate two unrelated tables, Table_A and Table_B, and show them in one output. Here is my answer to this unusual question.
Puzzle – Datatime to DateTime2 Conversation in SQL Server 2017
At PASS, SQL Server expert Christopher Savage showed me a puzzle on DateTime to DateTime2 conversion in SQL Server 2017. I still have no answer, so can you solve it?
SQL SERVER – Puzzle – Why Such a Complicated Execution Plan for a Single Row, Single Table Query?
A simple puzzle: why does SQL Server show such a complicated execution plan for a single row, single table query on WideWorldImporters? Try to solve it.
SQL SERVER – Puzzle – How Does YEAR Function Work?
SELECT YEAR(35000/20) returns 1904, which looks strange. This puzzle shows how the YEAR function treats a plain integer. Can you explain the result?
Asterisk Instead of a Number: A SQL Server Puzzle
This puzzle assigns a nine digit number to a varchar(8) variable and gets an asterisk instead of a number. The answer is an implicit conversion that does not fit. The post tests which data types behave this way, which ones raise an error, and how to size the variable.





