In SSMS (SQL Server Management Studio) debugger shows question mark for substring's return value when called from a function
I have a query with these two lines
SELECT SUBSTRING(N'אאא',1,1);
SELECT dbo.testsubstring5(N'א');
I put a breakpoint on the first and hit debug.
As you can see SUBSTRING works fine so far. That's when outside of the function call.
Now we when we go inside dbo.testsubstring5
then for some reason SUBSTRING
doesn't output the correct result in the debugger, though it does still work correctly outside of the debugger.
Look at the watch window of the debugger in the picture below
Notice the problem, that
SUBSTRING(@str,1,1)
fails, it gives the result of ?
Also as you see in that watch window, UNICODE(SUBSTRING(@str,1,1))
gives the value of 63 which is the ASCII value of question mark.
The correct values are returned in the program though, for example, the watch window shows the correct values for @zzz, @zzz1, and @zzz2
So it seems to be an issue with the debugger window , for substring, when substring is called within a function. I must be missing something though I don't know what.