Itzik Ben-Gan


Itzik Ben-Gan is a contributing editor to SQL Server Pro and a cofounder of SolidQ. He teaches, lectures, and consults internationally. He's a SQL Server MVP and is the author of several books about T-SQL, including Microsoft SQL Server 2012 High-Performance T-SQL Using Window Functions (Microsoft Press).

Check out Itzik's Puzzled by T-SQL blog.
Twitter: @ItzikBenGan

intervals and counts
Intervals and Counts, Part 1
Learn how to identify discrete intervals and counts of overlapping source intervals.
Interval Queries in SQL Server
Interval-related queries tend to perform very inefficiently in SQL Server. Itzik presents an ingenious solution based on the Relational Interval Tree (RI-tree) model.
Unwanted T-SQL Expression Failures 1
Itzik discusses expression failures in T-SQL queries and presents a proposal to Microsoft for a new T-SQL feature called TRY_EXPRESSION that would provide a more general solution for preventing expression failures.
Some differences between the COALESCE and ISNULL functions make COALESCE preferable, whereas others make ISNULL preferable. Learn the differences, to make an educated decision about which to use.
Copying Data with Dependencies 2
Itzik uses a simple generic data model to demonstrate how to copy data from one set of related tables to another, including dependent rows, while preserving the correct relationships between the rows.
CTEs with Multiple Recursive Members, Part 2
Itzik explains how to use a recursive CTE with multiple recursive members to draw a Koch snowflake.
CTEs with Multiple Recursive Members 2
Itzik provides two examples of CTEs with multiple recursive members: genealogy-related queries and the nested set model for representing graphs.
SQL Server 2012 Solutions for Median Calculation 1
Itzik examines new T-SQL features in SQL Server 2012 for computing the median. The type of median calculation he focuses on is one that assumes a continuous distribution model.
red jigsaw puzzle with missing piece
T-SQL Puzzle 4
Itzik presents a puzzle based on the British game show Blockbusters. See whether you can use T-SQL to solve the puzzle.
black calculator keys
Calculate Percentiles
Use T-SQL to implement statistical calculations such as percentile and percentile rank.
road sign pointing to success and failure
Combining Distinct and Non-Distinct Aggregates 3
Itzik presents an optimization improvement related to queries that involve both distinct and non-distinct aggregate computations.
small island in the middle of the ocean
Solving Gaps and Islands with Enhanced Window Functions
SQL Server 2012 provides enhanced window functions to help deal with gap and island problems.
MERGE Statement Tips 2
Itzik discusses several tips for using the T-SQL MERGE statement: preventing MERGE conflicts, understanding that the MERGE ON clause isn’t a filter, realizing that the MERGE USING clause is like the FROM clause in a SELECT statement, and referring to source table elements in the OUTPUT clause.
red percentage key on a calculator
Inverse Distribution Functions
Itzik provides pre-SQL Server 2012 solutions to using ordered set functions for computation of percentiles.
Ordered Set Functions
Various types of calculations can be implemented as ordered set functions, although you currently must rely on workarounds to accomplish this task because SQL Server 2012 doesn't support ordered set functions.

Digital Magazine Archives

Browse back issues of SQL Server Pro, from January 2007 through the last issue published in April 2014. Find the back issues here.


From the Blogs
business people around a table and laptop
Oct 9, 2014

AlwaysOn Availability Groups and SQL Server Jobs, Part 10: Dynamic Detection Gotcha #3

You can interject a SQL Server Job Step into your Jobs and have this new/injected Job Step do some checking for you. Here's a look at everything that’s involved in such an approach....More
Man holding a piece of paper with the word GOTCHA
Oct 7, 2014

AlwaysOn Availability Groups and SQL Server Jobs, Part 9: Dynamic Detection Gotcha #2 3

Given that a USE statement is parsed before code is actually run, there are a few options that could be used as a around when it comes to detecting whether or not code should be run....More
Oct 2, 2014

AlwaysOn Availability Groups and SQL Server Jobs, Part 8: Dynamic Detection Gotcha #1 1

Learn about why the option of dynamically detecting whether or not to run a SQL Server Job at execution time is quite a bit more problematic than you might think....More
SQL Server Pro Forums

Get answers to questions, share tips, and engage with the SQL Server community in our Forums.

Sponsored Introduction Continue on to (or wait seconds) ×