Link to home
Create AccountLog in
Avatar of Rickzzz
Rickzzz

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of Máté Farkas
Máté Farkas
Flag of Hungary image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
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

Avatar of Rickzzz
Rickzzz

ASKER

Vitor - thanks for the input.
Avatar of Rickzzz

ASKER

Thanks!