Monday, April 18, 2005

To Print A to Z Using SQL Query



This is Print A-Z
------------------------
DECLARE @LETTER CHAR(1),
@I INT
SET @I=65
WHILE(@I< = 90)
BEGIN
SET @LETTER = CHAR(@I)
SET @I=@I+1;
SELECT @LETTER
END

This is print a-z
---------------------------
DECLARE @LETTER CHAR(1),@I INT
SET @I=97
WHILE(@I< =122)
BEGIN
SET @LETTER = CHAR(@I)
SET @I=@I+1;
SELECT @LETTER
END

1 comment:

Anonymous said...

Hey printing A-Z is working fine.
But there is a small bug in printing a-z. Juz run the code. it will print the character a only.

u have place the statement
'SELECT @LETTER' before the 'END' statement.