To print pattern we use replicate function in sql. The following code draws pyramid triangle with star character. You can change row count changing max value.
1 2 3 4 5 6 7 8 |
Declare @i int,@max int Set @i =1 Set @max = 11 While(@i<=@max) Begin Print Space((@max-@i)/2) + replicate('X',@i) Set @i = @i + 2 End |
Result of Code