Search This Blog

Art of SQL

Open Query Analyser, Set the result mode as 'text' (Or press 'ctrl + T'). Copy the following and run


--Open Query Analyser, Set the result mode as 'text' (Or press 'ctrl + T'). Copy the following and run



set nocount On

declare @tab table (i int identity, j varchar(1000))
DECLARE @one varchar(100)
DECLARE @two varchar(100)

SET @one= char(124)+CAST(0x4F7C as varchar)
SET @two = char(124)+CAST(0x2F5E5C as varchar)+char(124)

INSERT INTO @tab SELECT REPLICATE(' ',24)+CHAR(33)
INSERT INTO @tab SELECT REPLICATE(' ',23)
UPDATE @Tab
SET j = j+CHAR(47)+CHAR(94)+CHAR(92)
WHERE i = SCOPE_IDENTITY()
INSERT INTO @tab SELECT REPLICATE(' ',21)+CHAR(47)+ replicate(' ',5)+CHAR(92)
INSERT INTO @tab SELECT REPLICATE(' ',4)+CHAR(33)+ replicate(' ',13)
UPDATE @Tab
SET j = j+ CHAR(33)+' '+char(40)+REPLICATE(' ',7)+char(41)+SPACE(1)+char(33)
WHERE i = SCOPE_IDENTITY()
UPDATE @Tab
SET j = j+space(13)+char(33)+space(1)
WHERE i = SCOPE_IDENTITY()

INSERT INTO @tab SELECT REPLICATE(' ',3)+char(47)+char(94)+char(92)
UPDATE @TAB
set J = J+SPACE(2)+CHAR(124)
WHERE I = SCOPE_IDENTITY()

UPDATE @TAB
set J = J+SPACE(8)+char(47)+char(94)+char(92)+SPACE(1)+CHAR(92)
WHERE I = SCOPE_IDENTITY()

UPDATE @TAB
set J = J+replicate('_',5)+char(47)+SPACE(1)+char(47)
WHERE I = SCOPE_IDENTITY()

UPDATE @TAB
set J = J+CHAR(94)+char(92)+SPACE(8)
WHERE I = SCOPE_IDENTITY()




INSERT INTO @tab SELECT REPLICATE(' ',3)

UPDATE @tab
SET j = j + @One
WHERE i =SCOPE_IDENTITY()

UPDATE @tab
SET j = j + REPLACE(@two,'|',' ')
WHERE i =SCOPE_IDENTITY()


UPDATE @tab
SET j = j + SPACE(5)+CAST(0x28202020297C as Varchar)
WHERE i =SCOPE_IDENTITY()

UPDATE @tab
SET j = j + REPLICATE('-',5)+Char(124)+CAST(0x2820202029 as varchar)
WHERE i =SCOPE_IDENTITY()


UPDATE @tab
SET j = j + SPACE(5)+REPLACE(@two,'|',' ')+@One
WHERE i =SCOPE_IDENTITY()

UPDATE @TAB
set J = J+CHAR(124)+SPACE(2)+char(47)
WHERE I = SCOPE_IDENTITY() -1


UPDATE @TAB
set J = J+char(94)+char(92)
WHERE I = SCOPE_IDENTITY() -1


INSERT INTO @tab SELECT REPLICATE(' ',3)+CAST(0x7C5F7C207C2D7C as varchar)+space(2)
UPDATE @tab
set j= J+CHAR(124)+char(94)+SUBSTRING('---',1,1)+Char(94)+char(124)
WHERE I = SCOPE_IDENTITY()

UPDATE @tab
set j= J+replicate('-',3)+char(124)+char(124)+replicate('-',5)
WHERE I = SCOPE_IDENTITY()

update @tab
SET j = j+CAST(0x7C7C2D2D2D7C5E2D5E7C20207C2D7C207C5F7C as varchar)
WHERE I = SCOPE_IDENTITY()




INSERT INTO @tab SELECT REPLICATE(' ',3)+@one+space(1)+@one
update @tab
SET j = j+Space(2)+@two+Right(@two,4)+Char(124)
WHERE I = SCOPE_IDENTITY()

update @tab
SET j = j+SPACE(2)+'!'+space(2)+'|'+@two+RIGHT(@two,4)
WHERE I = SCOPE_IDENTITY()

update @tab
SET j = j+SPACE(2)+@one+Space(1)+@one
WHERE I = SCOPE_IDENTITY()

INSERT INTO @tab SELECT REPLICATE(' ',3)+ REPLACE(@one,'O','-')+SPACE(1)+REPLACE(@one,'O','-')
update @tab
SET j = j+SPACE(2)+REPLACE(REPLACE(REPLACE(@two,'/','|'),'^','_'),'\','|')
WHERE I = SCOPE_IDENTITY()

update @tab
SET j = j+RIGHT(REPLACE(REPLACE(REPLACE(@two,'/','|'),'^','_'),'\','|'),4)+LEFT(REPLACE(REPLACE(REPLACE(@two,'/','|'),'^','_'),'\','|'),1)

WHERE I = SCOPE_IDENTITY()

update @tab
SET j = j+REPLACE(@two,'|',' ')+'|'+REPLACE(REPLACE(REPLACE(@two,'/','|'),'^','_'),'\','|')
WHERE I = SCOPE_IDENTITY()

update @tab
SET j = j+CAST(0x7C5F7C7C as char(6))+REPLACE(@one,'O','-')+space(1)+REPLACE(@one,'O','-')
WHERE I = SCOPE_IDENTITY()



INSERT INTO @tab(j)
SELECT REPLACE(j,'!',' ') FROM @tab
WHERE i = SCOPE_IDENTITY()-1



UPDATE @tab
SET j = Stuff(j,23,1,'(')
WHERE i = SCOPE_IDENTITY()

UPDATE @tab
SET j = Stuff(j,27,1,')')
WHERE i = SCOPE_IDENTITY()

INSERT INTO @tab(j)
SELECT REPLACE(REPLACE(j,'O','-'),'/^\',SPACE(3)) FROM @tab
WHERE i = SCOPE_IDENTITY()-1

UPDATE @tab
SET j = Stuff(j,23,1,'|')
WHERE i = SCOPE_IDENTITY()

UPDATE @tab
SET j = Stuff(j,27,1,'|')
WHERE i = SCOPE_IDENTITY()

INSERT INTO @tab(j)
SELECT REPLACE(j,'O','-') FROM @tab
WHERE i = SCOPE_IDENTITY()

INSERT INTO @tab SELECT REPLICATE(' ',3)+CAST(@one as Char(4))+CAST(REPLACE(@one,'O','_') as Char(5))
UPDATE @tab
SET j =j+'|'+REPLICATE('_',3)+'|'+REPLICATE('_',3)+REPLICATE('|',3)+REPLICATE('_',3)+REPLICATE('|',3)
WHERE i = SCOPE_IDENTITY()

UPDATE @tab
SET j =j+REPLICATE('_',3)+'|'+REPLICATE('_',3)+'|'
WHERE i = SCOPE_IDENTITY()

UPDATE @tab
SET j =j+SPACE(2)+REPLACE(@one,'O','_')+Space(1)+@ONE
WHERE i = SCOPE_IDENTITY()

INSERT INTO @tab
SELECT SPACE(3)+REPLACE(@one,'O','_')

UPDATE @tab
SET j = j+REPLICATE('_',37)+REPLACE(@one,'O','_')
WHERE i = SCOPE_IDENTITY()

INSERT INTO @tab SELECT ''
INSERT INTO @tab SELECT REPLICATE(' ',51)+CAST(0x417274204279203A2020416E6565736820 as varchar(40))

SELECT J from @tab

No comments: