All Type Coding

Search Here

How to print a triangle in sql server.?

Declare @x varchar(20)=0,@y varchar(20)=10
while(@y>0)
begin
print space(@y)+replicate('*',@x)+replicate('*',@x+1)
set @y=@y-1
set @x=@x+1
end
Output will be


          *
         ***
        *****
       *******
      *********
     ***********
    *************
   ***************
  *****************
 *******************



No comments :

Post a Comment