I have something si开发者_StackOverflow中文版milar 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:
AND ipdp.UserID != ISNULL(dbo.fn_userid(ipdp.ItemID), -1)
加载中,请稍侯......
精彩评论