I need to generate multiple random values under SQL Server 2005 and somehow this simply wont work
with Random(Value) as
(
select rand() Value
union all
select rand() from Random
)select top 10 * from Random
Whats the preffered workaround?
have you tries something like this (found at http://weblogs.sqlteam.com ) :
create a function
then you can call it in your selects as normal Select dbo.RandNumber() , * from myTable
or from their comments:
I'm currently using this:
but that seems overly hackish :S Why doesnt rand get reevaluated in the first version?