Monday 21 September 2015

                             SQL Query to write A to Z 

           Without Knowing the ASCII value of any Character



 declare @start int,@stop int     --We declare start and stop variable to hold from and to value
set @start= ASCII('a')              --We get ASCII value of 'a' in start variable
set @stop= ASCII('z')              --We get ASCII value of 'a' in start variable
while(@stop>=@start)             --We start loop. Loop terminate if start value is greater than stop value
begin
print CHAR(@start)
set @start=@start + 1
end





Now If you want to print A to Z means in Capital then we should set 

set @start= ASCII('A') 
set @stop= ASCII('z')  

And rest code will be the same.

Also we can use This code to print all numbers between two numbers.