Blog Post

A SQL Server Christmas Card

,

Merry Christmas everyone!

DECLARE @hohoho char(100)
DECLARE @bells smallint
DECLARE @tiers smallint
DECLARE @maxtiers smallint
SELECT @hohoho = ' ', @tiers = 1, @bells = 1, @maxtiers = 6
PRINT @hohoho
WHILE @tiers < @maxtiers
BEGIN
SELECT @bells = POWER(@tiers,2), @hohoho = ' '
WHILE @bells < 12*@tiers
BEGIN
SET @hohoho =  STUFF(@hohoho, (DATALENGTH(@hohoho)/2)-(@bells/2), @bells,REPLICATE('*', @bells))
PRINT @hohoho
SET @bells = @bells+4
END
SET @tiers = @tiers+1
END
SELECT @bells = @tiers, @hohoho = ' '
WHILE @tiers >=0
BEGIN
SET @hohoho =  STUFF(@hohoho, (DATALENGTH(@hohoho)/2)-(@bells/2), @bells,REPLICATE('*', @bells))
IF @tiers < @maxtiers
BEGIN
SET @hohoho =  STUFF(@hohoho, (DATALENGTH(@hohoho)/2)+(@bells*2), @bells*3, REPLICATE('*', @bells*3))
IF NOT (@tiers = @maxtiers-1) AND NOT (@tiers = @maxtiers/2) AND NOT (@tiers = (@maxtiers-2)/2 AND @maxtiers > 5)  AND NOT (@tiers = 0)
SET @hohoho =  STUFF(@hohoho, (DATALENGTH(@hohoho)/2)+(@bells*2)+1, @bells*3-2, REPLICATE(' ', @bells*3-2))
SET @hohoho =  STUFF(@hohoho, (DATALENGTH(@hohoho)/2)+(@bells*2)+(@bells*3)/2, 2, REPLICATE('*', 2))
END
PRINT @hohoho
SET @tiers = @tiers-1
SELECT @hohoho = ' '
END

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating