Question
declare @n int, @j tinyint declare @rec varchar(30) set @j=0 set @rec= '' while (@j
declare @n int, @j tinyint
declare @rec varchar(30)
set @j=0
set @rec= ''
while (@j<=9)
begin
set @rec=@rec +char(65+@j)
set @j=@j+1
end
print @rec
print reverse (@rec)
Output
ABCDEFGHIJ
JIHGFEDCBA
Program 2
declare @n int, @j tinyint, @m tinyint, @k tinyint
declare @acc varchar(30),@dec varchar(30)
set @j=1
set @n=65
set @acc= CHAR(@n)
while (@j<=9)
begin
set @n=@n+1
set @acc=@acc +char(@n)
set @j=@j+1
end
print @acc ---
set @k=1
set @m=75
set @dec= CHAR(@m)
while (@k<=9)
begin
set @m=@m-1
set @dec=@dec +char(@m)
set @k=@k+1
end
print @dec
I have these two SQL programs, but I can only use one print statement and one nested loop in each, can someone help me do that and get the same output?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started