Tags

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,


T-SQL Query | [ The ASCII Puzzle ]

Puzzle Statement

We have characters A to Z if the input is A then it should be print Z, if the input is B then o/p will be Y.

Sample Input & Corresponding Expected Output

Sample Input  Expected Output
Z A
A Z
B Y
C X

UPDATE – 25-Apr-2015 – Solution 1


--

DECLARE @t AS VARCHAR(1)= 'C'
SELECT CHAR(ASCII('A') + ASCII('Z') - ASCII(@t)) 

--

Add a comment if you have any other solution in mind. We all need to learn.

Keep Learning

http://MSBISkills.com

Advertisements