Lay out the Carpet

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

USE master
DECLARE 
@y char='.',
@ varchar(20) = 'abcd'
DECLARE @o varchar(max)


SELECT @o=
  string_agg(iif(h>k/2,@y,substring(@,h+1,1))+iif((n+1)%k=0,char(13),@y),'')
FROM
  (
    SELECT abs(k/2-n%k)+abs(k/2-n/k)h,*
    FROM
    (
      SELECT number n,len(@)*2-1k,*
      FROM spt_values
    )c
  WHERE n<k*k and'P'=type
  )d

PRINT replace(@o,char(13),char(13)+char(10))

Enter Parameters

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