Jun 22

Fun Code Friday – SQL Binary Generator

I was daydreaming about some SQL code the other day, and wrote a note to myself to investigate.

I’ve always been interested in writing loops to output sequential data. I don’t know why, I just do.

So, here is some SQL that will generate some binary.

DECLARE @b TABLE (c VARCHAR(1))
INSERT INTO @b VALUES (0)
INSERT INTO @b VALUES (1)

SELECT	b1.c + b2.c + b3.c + b4.c + b5.c + b6.c + b7.c + b8.c
FROM	@b b1, @b b2, @b b3, @b b4, @b b5, @b b6, @b b7, @b b8
ORDER BY 1