Posted by Alex Kuznetsov on 11/30/06 16:44
Douglas,
For a limited number of images you can select all possible combinations
as follows:
DECLARE @n INT
SET @n = 5
SELECT P.Number AS Combination, N.Number
FROM
--- Numbers is a table with numbers from 0 to 9999
(SELECT Number FROM Numbers WHERE Number BETWEEN 0 AND (@n-1)) N
JOIN
(SELECT Number FROM Numbers WHERE Number BETWEEN 1 AND POWER(2,@n)) P
ON P.Number & POWER(2,N.Number) > 0
ORDER BY P.Number
-----------------------
Alex Kuznetsov
http://sqlserver-tips.blogspot.com/
http://sqlserver-puzzles.blogspot.com/
[Back to original message]
|