Posted by Alexander Kuznetsov on 02/15/06 20:26
yet another approach is to use rand():
create view wrapped_rand_view
as
select rand( ) as random_value
go
create function wrapped_rand()
returns float
as
begin
declare @f float
set @f = (select random_value from wrapped_rand_view)
return @f
end
select c.customer, dbo.wrapped_rand() wrapped_rand
into #t
from customers c
select top 1 percent c.* from customers c join #t on
c.customer=#t.customer
order by wrapped_rand
[Back to original message]
|