Query Generates Winning Lottery Numbers!


Editor's Note: We hope you enjoy our attempts at April Fool's humor in the following article!

square download the code icon

As one of SQL Server Magazine’s most popular authors, Itzik Ben-Gan gets plenty of requests from readers to help them solve their T-SQL coding problems. But recently he got a request that was a little different.

“Dear Itzik: I’ve been a DBA for 10 years, and I love my job. But all my friends make a lot more money than me; they’re investment bankers or lawyers, or they sell stuff on eBay. I’ve had it with working harder than they do and having less to show for it. Since you’re a T-SQL expert, I thought you of all people could write a query to generate winning lottery numbers. If I had such a query, I’d never have to work again and would be the envy of my friends. Can you help me?”

As usual, Itzik came through and created the T-SQL query in Listing A (some code lines are wrapped in the print version). If it’s lottery numbers you want, this query delivers. See if you can figure out how it works!

Read more about this topic by visiting "Get Foolish."

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.