APPLY Yourself

Abstract

Microsoft introduced the APPLY operator in SQL Server 2005. This under-used, non-standard operator can help us solve a number of common (and not-so-common) problems with elegant code which performs well. We will look several problem spaces in which the APPLY operator shines, such as joining to table-valued functions, getting the top N child records for each parent record, string splitting, and word matching. With the use of these examples, we will gain a deeper understanding of when to use the APPLY operator.


Slides

The slides are available in HTML 5 format. All modern browsers (including tablets and phones) should be able to navigate the slides successfully. Sadly, Internet Explorer 8 is not a modern browser and cannot view these slides. If you use IE 8 and need these slides, contact me and I can get them to you in a different format.

The slides are licensed under Creative Commons Attribution-ShareAlike.


Demo Code

The demonstration code is available in ZIP format. These demos give you the opportunity to experiment with the APPLY operator.

The source code is licensed under the terms offered by the GPL. The slides are licensed under Creative Commons Attribution-ShareAlike.