Printing Your Name as a Triangle in SQL Server

Hello to everyone,

In this article, I will talk about how you can print your name as a triangle in SQL Server.

In SQL Server, such examples will improve your algorithm logic.

You can easily do this by using the code below.

DECLARE @i INT,
        @word VARCHAR(20);
SET @i = 0;
SET @word = 'YAVUZSELIMKART';
WHILE (@i < LEN(@word))
BEGIN
    SET @i = @i + 1;
    PRINT SUBSTRING(@word, 1, @i);
END;

When you run the code, you will get a result like the one below.

Printing Your Name as a Triangle in SQL Server

As you can see, your name is written in the form of a triangle.

Good luck to everyone in business and life.

343 Views

Yavuz Selim Kart

I try to explain what I know in software and database. I am still improving myself by doing research on many programming languages. Apart from these, I am also interested in Graphic Design and Wordpress. I also have knowledge about SEO and Social media management. In short, I am a determined person who likes to work hard.

You may also like...

Don`t copy text!