Hmm, then that is strange, I can't see anything wrong with your Case statement, and in my own tests I can't reproduce the problem. Is it possible that the...
The only thing I could add is that maybe you could put the 'EXECUTE dbo.sp_Procedure' line inside the function, and then using the function in your select statement. Not...