I have something similar to the following WHERE clause in my SQL statement:
AND (ipdp.UserID!=dbo.fn_userid(ipdp.ItemID) OR dbo.fn_userid(ipdp.ItemID) IS NULL)
However, I don’t like how dbo.fn_userid function is being ran twice. How can I improve this line of code so that it only has to be ran once?
ipdp.UserID is always a Non-NULL Integer value
dbo.fn_userid can return a NULL or an Integer value
Cheers.
Try: