User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

BEGIN

  --
  -- Run with results to text.
  --
  SET NOCOUNT ON;
  DECLARE @TreeStr VARCHAR(64);
  SET @TreeStr = 'HAPPYHOLIDAYSTOEVERYONE!';
  --
  WITH cteTreeBranches
  AS (SELECT 1                       AS [Level],
             CONVERT(VARCHAR(64),'') AS [Branches]
      UNION ALL
      SELECT tb.Level + 1            AS [Level],
             CASE WHEN tb.Level >= 25
                THEN '                      !!!!!'
                ELSE CONVERT(VARCHAR(64), SPACE(25 - tb.level)     +
                             REPLICATE(SUBSTRING(@TreeStr, tb.Level, 1), tb.Level) +
                             REPLICATE(SUBSTRING(@TreeStr, tb.Level, 1), tb.Level - 1))
             END                     AS [Branches]
      FROM cteTreeBranches tb
      WHERE tb.[Level] < 28)
  --
  SELECT Branches
  FROM  cteTreeBranches;
END;

Comments  

+1 # SW 2017-12-06 21:18
Share your SQL Yahtzee game!
Reply | Reply with quote | Quote
0 # Jeff 2017-12-09 02:35
Lol...maybe. Was thinking about the sudoku game 8)
Reply | Reply with quote | Quote

Add comment


Security code
Refresh

0
0
0
s2sdefault