﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by bitbucket  / APPLY - 2 / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 23 May 2013 11:09:48 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>[quote][b]carl.landry (10/2/2012)[/b][hr]I just don't get what to do with this APPLY keyword.The query can be redone using a LEFT OUTER JOIN, which results in the same output and the same plan.Is APPLY easier to read for you? Are there cases where APPLY is the only way to go?[/quote][quote][b]carl.landry (10/2/2012)[/b][hr]Looks like I found an answer. The [url=http://technet.microsoft.com/en-us/library/ms175156(v=sql.105).aspx]documentation shows[/url] an example where APPLY is used to provide an argument to a table-function that require a parameter. It looks like it can't be done with a JOIN.[/quote]It's not just for calling user-defined table-valued functions. APPLY is also the only way to include a subquery that is correlated to another table in the same FROM clause. Your first post (that the query can be redone using LEFT OUTER JOIN) is not correct; when you do that, it will result in an error. (Okay, technically you are correct; with enough effort you can redo the query with LEFT OUTER JOIN, but that would require a non-trivial effort to rewrite the query, and the result would be harder to read and maintain).</description><pubDate>Fri, 05 Oct 2012 01:34:54 GMT</pubDate><dc:creator>Hugo Kornelis</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>thanks for the question</description><pubDate>Thu, 04 Oct 2012 01:29:56 GMT</pubDate><dc:creator>demonfox</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Thanks for the question.</description><pubDate>Wed, 03 Oct 2012 12:14:16 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Looks like I found an answer. The [url=http://technet.microsoft.com/en-us/library/ms175156(v=sql.105).aspx]documentation shows[/url] an example where APPLY is used to provide an argument to a table-function that require a parameter. It looks like it can't be done with a JOIN.</description><pubDate>Tue, 02 Oct 2012 08:18:44 GMT</pubDate><dc:creator>carl.landry</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>I just don't get what to do with this APPLY keyword.The query can be redone using a LEFT OUTER JOIN, which results in the same output and the same plan.Is APPLY easier to read for you? Are there cases where APPLY is the only way to go?</description><pubDate>Tue, 02 Oct 2012 08:16:01 GMT</pubDate><dc:creator>carl.landry</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Coffee was a prerequisite in order for me to get this right.</description><pubDate>Mon, 01 Oct 2012 12:58:29 GMT</pubDate><dc:creator>Jim_K</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Nice question! Glad I had my coffee first!</description><pubDate>Mon, 01 Oct 2012 11:27:35 GMT</pubDate><dc:creator>KWymore</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Simply nice one. :-)</description><pubDate>Mon, 01 Oct 2012 10:10:02 GMT</pubDate><dc:creator>Raghavendra Mudugal</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Good question Ron.If anyone wants to learn more about using the Apply operator, check out the "Using APPLY" links in my signature block for some great articles written by Paul White. He does an excellent job of walking you through it.</description><pubDate>Mon, 01 Oct 2012 07:52:18 GMT</pubDate><dc:creator>WayneS</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Thanks for the great question.</description><pubDate>Mon, 01 Oct 2012 06:01:37 GMT</pubDate><dc:creator>Dana Medley</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Never heard of "Apply" before.  Nice to know that "The difference between join and APPLY operator becomes evident when you have a table-valued expression on the right side and you want this table-valued expression to be evaluated for each row from the left table expression"Learn something again.Thanks!</description><pubDate>Mon, 01 Oct 2012 05:46:45 GMT</pubDate><dc:creator>tilew-948340</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Nice question.Glad I looked at it after breakfast, not before - without fuel I would probably have calculated 2+2+2+1+1+2 = 7 or something equally silly. Don'y you feel a bit cruel inflicting such advanced arithmetic on us on a Monday morning? :-D</description><pubDate>Mon, 01 Oct 2012 05:28:13 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Great question on a Monday morning.  Gets me back on track after Fridays question.</description><pubDate>Mon, 01 Oct 2012 05:21:37 GMT</pubDate><dc:creator>(Bob Brown)  </dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Grrrr!!! Seems I can't count properly on a Monday morning.Good question though, Ron!</description><pubDate>Mon, 01 Oct 2012 04:41:49 GMT</pubDate><dc:creator>Jan Van der Eecken</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Good way to wake up the brain on a monday morning.Thanks, Ron</description><pubDate>Mon, 01 Oct 2012 03:31:24 GMT</pubDate><dc:creator>Stewart "Arturius" Campbell</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Good and interesting question for a Monday, thanks.</description><pubDate>Mon, 01 Oct 2012 03:04:19 GMT</pubDate><dc:creator>DugyC</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>nice question ...thanks.</description><pubDate>Mon, 01 Oct 2012 01:24:15 GMT</pubDate><dc:creator>demonfox</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Great question Ron. Almost missed that OUTER keyword on this Monday morning. :-)</description><pubDate>Sun, 30 Sep 2012 23:17:37 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Very nice question Ron. Thanks for posting :-)</description><pubDate>Sun, 30 Sep 2012 22:28:56 GMT</pubDate><dc:creator>Lokesh Vij</dc:creator></item><item><title>RE: APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Thanks for question.  Easy one on a lazy morning.Fitz</description><pubDate>Sun, 30 Sep 2012 00:39:48 GMT</pubDate><dc:creator>Mark Fitzgerald-331224</dc:creator></item><item><title>APPLY - 2</title><link>http://www.sqlservercentral.com/Forums/Topic1366232-1222-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/questions/APPLY/93304/"&gt;APPLY - 2&lt;/A&gt;[/B]</description><pubDate>Sun, 30 Sep 2012 00:37:33 GMT</pubDate><dc:creator>bitbucket-25253</dc:creator></item></channel></rss>