This month's discount Comprehensive Database Performance Health Check · Testimonials
SQLAuthority with Pinal Dave
Home
  • Consulting
    • Health Check
  • Free Videos
  • All Articles
    • AI
    • SQL Performance
    • SQL Tips and Tricks
    • Interview Questions and Answers
    • SQL Puzzle
    • SQL Video
    • SQLAuthority News
    • Personal
  • Books
  • Consulting
Gouache painting of a picket fence in a meadow with one vermilion picket leaning the opposite way

SQL Agent Job Backslash Puzzle: Why Both Rows Were Deleted

July 18, 2019
Pinal Dave
SQL Puzzle
SQL Delete, SQL Scripts, SQL Server Agent

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.

Read More
Gouache painting of three wooden shape sorter boxes with a single vermilion peg in front of them

Delete Qualified Rows From Multiple Tables: A SQL Puzzle

July 13, 2019
Pinal Dave
SQL Puzzle
SQL Delete, SQL Performance, SQL Scripts

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.

Read More
SQL Server query with expected results.

SQL SERVER – Relating Unrelated Tables – A Question from Reader

December 10, 2018
Pinal Dave
SQL Puzzle
SQL Scripts, SQL Server

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.

Read More
Result column flipping between 1 and 0.

Puzzle – Datatime to DateTime2 Conversation in SQL Server 2017

November 16, 2018
Pinal Dave
SQL Puzzle
SQL DateTime, SQL Scripts, SQL Server, 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?

Read More
Execution plan of a query with a single row and single table.

SQL SERVER – Puzzle – Why Such a Complicated Execution Plan for a Single Row, Single Table Query?

July 13, 2018
Pinal Dave
SQL Puzzle
Execution Plan, SQL Scripts, SQL Server

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.

Read More
Year 1904 Answer.

SQL SERVER – Puzzle – How Does YEAR Function Work?

March 13, 2018
Pinal Dave
SQL Puzzle
SQL DateTime, SQL Function, SQL Scripts, SQL Server

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?

Read More
Gouache painting of an open wooden puzzle box with a small vermilion paper boat inside.

Asterisk Instead of a Number: A SQL Server Puzzle

March 6, 2018
Pinal Dave
SQL Puzzle
SQL Datatype, SQL Scripts, SQL Stored Procedure, SQL Variable

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.

Read More
Previous 1 2 3 4 5 6 … 22 Next
  • Books
  • Testimonials
  • Privacy Policy

© 2006 – 2026 All rights reserved. pinal @ SQLAuthority.com