-- Select random 6 numbers delimited with comma
-- SQL 2005 only .
-- Executing this query multiple times will give
-- different number combinations between 1 -49
with l0 as ( select 0 as c union all select 0 ),
l1 as (select 0 as c from l0 as a, l0 as b),
l2 as (select 0 as c from l1 as a, l1 as b),
l3 as (select 0 as c from l2 as a, l2 as b),
nums as (select top(49) row_number() over(order by c) as n from l3),
choice as (select top(6) n from nums order by checksum(newid()))
select stuff( (select ',' + cast(n as varchar(10)) as [text()]
from choice order by n for xml path('')), 1, 1, '' );
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment