Hi Team,
I have been observed that many of the interviews people are asking printing the pyramid like below by using SQL server.
So I am giving a script to that one
DECLARE @lclMaxLevel INT=5
DECLARE @lclPrintCount INT =0
WHILE @lclMaxLevel > 0
BEGIN
PRINT Space(@lclMaxLevel)
+ Replicate('*', @lclPrintCount)
+ Replicate('*', @lclPrintCount+1)
SET @lclMaxLevel=@lclMaxLevel - 1
SET @lclPrintCount=@lclPrintCount + 1
END
Output as follows:
Let me know if you have any doubts on this.
Thanks
SQL Srinivas
I have been observed that many of the interviews people are asking printing the pyramid like below by using SQL server.
So I am giving a script to that one
DECLARE @lclMaxLevel INT=5
DECLARE @lclPrintCount INT =0
WHILE @lclMaxLevel > 0
BEGIN
PRINT Space(@lclMaxLevel)
+ Replicate('*', @lclPrintCount)
+ Replicate('*', @lclPrintCount+1)
SET @lclMaxLevel=@lclMaxLevel - 1
SET @lclPrintCount=@lclPrintCount + 1
END
Output as follows:
Let me know if you have any doubts on this.
Thanks
SQL Srinivas