I am writing a SQL Function that will take in a decimal and return the base32 representation of that decimal.
My problem is with the decimal to ascii conversion.
I am allowed to run the following query and return an ascii character
‘SELECT CHAR( 65 )’ which returns ‘A’
However in my function when I am trying to build my output string of letters, I am having trouble casting a bigint into a char, then concatenate that char to the end of a another char(which would be my output).
Sample line of code: ‘SET @OutputChar = @OutputChar + CAST( ( @Output + 55 ) AS CHAR(255) )’
What is the proper way to cast a bigint to char and then concatenate that char to another?
Thanks
How are you declaring @OutputChar?
If you have:
then every time you concantenate, it will truncate it to 255. CHAR includes the whitespace at the end, maybe you mean to use varchar instead of CHAR?