Answer: For the above pattern We can make use of spt_values table in master database; Otherwise we can generate the simple table too
SELECT REPLICATE( ' * ', number) CustomPattern
FROM (
SELECT distinct number
FROM master.dbo.spt_values
WHERE number between 1 and 5 and type='p'
) T
OUTPUT:
*
* *
* * *
* * * *
* * * * *
Asked In: Many Interviews |
Alert Moderator