Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

What is Cross Apply ? Expand / Collapse
Author
Message
Posted Thursday, July 25, 2013 10:29 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 11:11 PM
Points: 138, Visits: 383
Hi I'm newbie to SQL ...

Please explain in simpler words. What is Cross Apply ?

Examples pls...
Post #1477619
Posted Thursday, July 25, 2013 1:47 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 5:01 AM
Points: 13,605, Visits: 10,480
Simply put: you join a table with a table valued function.
This article explains the concept and has some examples:
SQL Server APPLY Basics




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1477713
Posted Thursday, July 25, 2013 7:45 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 3:50 AM
Points: 3,627, Visits: 5,268
Here are some additional links:

Understanding and Using APPLY (Part 1) by Paul White
Understanding and Using APPLY (Part 2) by Paul White
The Cascading (CROSS) APPLY by Chris Morris

And don't miss the first link in my signature for a neat way to UNPIVOT using CROSS APPLY.



My mantra: No loops! No CURSORs! No RBAR! Hoo-uh!

My thought question: Have you ever been told that your query runs too fast?

My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.


Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Learn to understand recursive CTEs by example.
Splitting strings based on patterns can be fast!
Post #1477825
Posted Thursday, July 25, 2013 7:52 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 1:55 PM
Points: 21,638, Visits: 15,305
You can also check out this series of blog posts
http://mattvelic.com/tsql-tuesday-17-roundup/




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1477829
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse