I have a stored procedure that uses a function inside it, and the function expects two parameters. My problem is related to performance issue, see below
CASE
WHEN (DATEDIFF(MINUTE,dbo.FunctionName(DatetimeField, DatetimeID), dbo.FunctionName(DatetimeField, DatetimeID))/60.0) > 8 THEN
(DATEDIFF(MINUTE,dbo.FunctionName(DatetimeField, DatetimeID), dbo.FunctionName(DatetimeField, DatetimeID))/60.0)
Else 0
END
Else
0
END)
Else
(DATEDIFF(MINUTE,dbo.FunctionName(DatetimeField, DatetimeID), dbo.FunctionName(DatetimeField, DatetimeID))/60.0)-T.lunch
END
as 'Total'
Now what I want to do is create a temporary table so that I can use it to call the function instead of calling the function every time it gets to these rows with hundreds of thousands of records. Any help is appreciated.
source
share