Tuesday, January 8, 2013

SQL Server - HNY with ChristmasTree

Execute below query in SQL Server

select
space(total-len(replicate(char(characters),no)))+ replicate(char(characters),no*2-1)

from
(
select top 10 row_number() over (order by name) as no, 17 as total, 210 as characters from sysobjects
)
as t

union all

select space(14)+replicate(char(124),5)

union all

select space(10)+cast(0x4861707079204E65772079656172 as varchar(100))



You will get a Christmas Tree as output.. Enjoy..