I have letter "a", "b", "c". I would like my results to be "b", "c", "d" in TSQL respectively. Would what I use to achieve this?
The English Alphabet consists of 26 letters: A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z.
Use ASCII to get the value of the character, add one, and use CHAR to convert the value back to a character. Save this answer.
Try this: char letter = 'c'; if (letter == 'z') nextChar = 'a'; else if (letter == 'Z') nextChar = 'A'; else nextChar = (char)(((int)letter) + 1); This way you have no trouble when the char is the last of the alphabet.
To increment a character in a Python, we have to convert it into an integer and add 1 to it and then cast the resultant integer to char. We can achieve this using the builtin methods ord and chr.
Use ASCII
to get the value of the character, add one, and use CHAR
to convert the value back to a character.
SELECT CHAR(ASCII('a') + 1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With