Wednesday, April 5, 2017

How To Print Star Triangle In SQL Server Using REPLICATE( ) Function

Print * Triangle In SQL Server Using REPLICATE( ) Function

 In SQL Server we can print * triangle in many methods.One of the simple method is here 



 /*

 PRINT STAR TRIANGLE IN SQL

 */

 DECLARE @Limit     INT =5
 DECLARE @Iteration INT =1

 WHILE (0<@Limit)
  BEGIN
   PRINT SPACE(@Limit-1)+REPLICATE('*',@Iteration)
   SELECT @Limit=@Limit-1
   SET @Iteration=@Iteration+2
 END


OUT PUT :


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




 

No comments:

Post a Comment

Comments system

Disqus Shortname

How To Print Star Triangle In SQL Server Using REPLICATE( ) Function

Print * Triangle In SQL Server Using REPLICATE( ) Function   In SQL Server we can print * triangle in many methods.One of the simple m...