• Be interested in seeing your final query and the function. Pretty sure you are thinking scalar function, but keep in mind that will give you a hit performance wise. Would need to see what you create to see if it could be modified to an in-line table valued function which could be used to improve the performance of your final query.