Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Cleveland DBA

Colleen Morrow is a SQL Server Consultant at UpSearch, a provider of DBA resources in northeastern Ohio. She has worked in the IT industry for 20 years, doing everything from technical support to development to database administration on Informix, Oracle, and SQL Server platforms.

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

Comments

Leave a comment on the original post [colleenmorrow.com, opens in a new window]

Loading comments...