TRY_CONVERT returns wrong result

Copper Contributor



I was relying on correct result of Try_Convert ( select try_convert(smallint,'+')), but instead of null, I've received 0 as a result. It is the same also with -


According to the documentation ( this should be not possible. Bug or am I missing something ?

I've tried it on SQL 2012 (latest SP4) and SQL 2019 (latest CU)




1 Reply

The result 0 is correct.

The plus and minus counts as numeric signs, an addition number is not mandatory here

Convert returns the same result


select convert(smallint, '+'), convert(smallint, '-')