>How do you know that both conditions where evaluated?
It first started when I found an error in this process. So, I later found that the error was caused because the function wasn't suppose to be called when Type=2 as the IIF() condition would map it to the first condition thus it wouldn't call the function. So, as I have only 5 keys, coming in from Temp cursor, where only one was Type=2, I found that the error came in when the function was called (2nd condition of IIF()) when Type=2. As per the SQL, when Type=2, the New.Url should be returned directly. But, even in that case, the second condition is evaluated.