Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

=+c. What is the GDP deflator for each of these years?

Answered: 1 week ago