Build an Alphabet Pyramid

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @i INT =5;

WITH C as(SELECT top(@i*2-1)number z
FROM master..spt_values WHERE'P'=type)SELECT
top(@i*2-1)SPACE(abs(z-@i+1)*2)+v+STUFF(reverse(v),1,3,'')FROM(SELECT
z,(SELECT top((@i-abs(@i-z-1)))char(65+z)+' 'FROM c
for xml path(''),type).value('.','varchar(52)')v FROM c)d

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results