| How to use generate binary sequences? |
|
Execute the following
Microsoft SQL Server T-SQL scripts in Management Studio Query Editor to create 8 bit ( 1 byte ) 256 combinations of 0-s and 1-s.
-- SQL bit column type - SQL binary data - SQL table variable
-- SQL cross join - Cartesian product for all combinations
USE AdventureWorks;
DECLARE @Binary TABLE(
Digit BIT
)
INSERT @Binary
VALUES(0) -- 0 is commonly interpreted as FALSE as logical operation result
INSERT @Binary
VALUES(1) -- 1 is commonly interpreted as TRUE as logical operation result
SELECT a.Digit AS Bit7,
b.Digit AS Bit6,
c.Digit AS Bit5,
d.Digit AS Bit4,
e.Digit AS Bit3,
f.Digit AS Bit2,
g.Digit AS Bit1,
h.Digit AS Bit0
FROM @Binary a
CROSS JOIN @Binary b
CROSS JOIN @Binary c
CROSS JOIN @Binary d
CROSS JOIN @Binary e
CROSS JOIN @Binary f
CROSS JOIN @Binary g
CROSS JOIN @Binary h
ORDER BY a.Digit,
b.Digit,
c.Digit,
d.Digit,
e.Digit,
f.Digit,
g.Digit,
h.Digit
GO
/* Partial results
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1
0 0 0 0 0 0 1 0
0 0 0 0 0 0 1 1
0 0 0 0 0 1 0 0
0 0 0 0 0 1 0 1
0 0 0 0 0 1 1 0
0 0 0 0 0 1 1 1
*/ |
| |
| SQLUSA.com
Home Page |
|
|
SQL Server Training at www.sqlusa.com.
Microsoft SQL Server 2012 Training Videos at www.sqlusa.com.
SQL Server 2008 Video Training at www.sqlusa.com.
SQL Server 2005 Training Videos at www.sqlusa.com.
|
|
|
FREE SS SQL / BI OLAP Short Videos on YOUTUBE.com |
|
Search SQLUSA FREE SQL Server Articles & FREE T-SQL Scripts |
Copyright 2005-2012, SMI Corp. All Rights Reserved.
SQL Server 2012 is a program product of Microsoft Corporation. SQL Server 2008 is a program product of Microsoft Corporation. SQL Server 2005 is a program product of Microsoft Corporation. SQL Server 2000 is a program product of Microsoft Corporation. |
|