To check palindrome I am using REVERSE
function of SQL Server.
I wanted to check how reverse function works with this sample code:
declare @string nvarchar
set @string = 'szaaa'
SELECT REVERSE(@string)
But the output was 's' in case of 'aaazs' which I expected. How should I capture the reverse? Is there any better way to find palindrome?
In SQL Server, always use lengths with the character types:
declare @string nvarchar(255);
set @string = 'szaaa';
SELECT REVERSE(@string);
The default length varies by context. In this case, the default length is "1", so the string variable only holds one character.
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