In a function I have a temporary table variable
DECLARE TABLE
(
d DATE
)
which contains some sorted dates:
DDate
2016-06-15
2016-05-11
2016-04-15
2016-03-15
2016-02-16
2016-01-14
I have to call a table-valued function
MyCompare(d1 DATE, d2 DATE)
in a loop for each pair (d, next d) until the returned table is empty. The function returns the current value of d. How can I achieve it?
SELECTstatement, the same way you do with any other function. If you want a TVF to get parameters from another table, use INNER JOIN or CROSS APPLY.MyCompare(d1 DATE, d2 DATE)really it returns table