• + 0 comments

    MSSQL Server:

    -- solution 1:
    WITH alls AS (
      SELECT cast('*' as varchar(50)) AS str, 1 as num
      UNION ALL
      SELECT cast(concat(str, ' *') as varchar(50)), num + 1
      FROM alls
      WHERE num < 20
    )
    select str
    from alls
    
    -- solution 2:
    WITH alls AS
      (SELECT 1 AS num
       UNION ALL 
       SELECT num + 1
       FROM alls
       WHERE num < 20)
    SELECT Replicate(' *', num)