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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!