To print pattern we use replicate function in sql. The following code draws right triangle with star character. You can change row count changing max value.
1 2 3 4 5 6 7 |
Declare @i int=1 Declare @max int = 10 While @i<@max Begin Print space(@max-@i)+replicate('*',@i) set @i = @i + 1 end |
Result of Code: