Reputation: 2201
I have a simple table with IDs:
ObjectId
----------
100
101
102
I'd would like to execute a function fn_GetStuff(Id) multiple times like this:
fn_GetStuff(100)
fn_GetStuff(101)
fn_GetStuff(102)
Is it possible to do this without using a loop?
I tried this it doesn't work:
SELECT *
FROM myTable
INNER JOIN fn_GetStuff(myTable.ObjectId)
Upvotes: 1
Views: 3627
Reputation: 2785
OP is using a in-line table valued function it looks like so they would need a CROSS APPLY
...
Select *
From myTable mt
Cross Apply schema.fn_GetStuff(mt.ObjectID) f
Upvotes: 6
Reputation: 6434
You don't need to join because there isn't another table. You should be okay to do this:
SELECT fn_GetSTuff(t.ObjectId)
FROM myTable t
Upvotes: 0
Reputation: 1269583
Assuming your function is a scalar-valued function, you can just do:
select fn_GetStuff(Objectid)
from myTable
If your function is table valued, then you would need to use cross apply
.
Upvotes: 2