CROSS APPLY Issue

Not much experience with CROSS APPLY. Running into an issue LEFT JOIN would generally resolve, though not applicable here.

select
 t.refID
 z.dataPiece
from
 MyDataTable t
    CROSS APPLY myFunction(t.refID) z

t.refID may not always be what myFunction expects or is null, therefore those t.records are dropped. So if there's 100 records in MyDataTable, only 90 may result. I can't arbitrarily change t.refID if NULL or not the expected combination of characters (It's a vehicle's VIN btw). I also can't change the function to deal with it, as its used in other applications. Ideally the function would simply return NULL as a JOIN would. Thanks in advance for any assistance.
RickzzzAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Máté FarkasDatabase Developer and AdministratorCommented:
You should use OUTER APPLY instead of CROSS APPLY.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vitor MontalvãoMSSQL Senior EngineerCommented:
Why not add a WHERE clause?
select
 t.refID
 z.dataPiece
from
 MyDataTable t
    CROSS APPLY myFunction(t.refID) z 
WHERE t.refID IS NOT NULL

Open in new window

0
RickzzzAuthor Commented:
Vitor - thanks for the input.
0
RickzzzAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.