Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Random distribution
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01275589
Message ID:
01275659
Views:
14
>>>>
>>>>SELECT TOP xxx  *, NEWID() as Test
>>>>       FROM YoutTable
>>>>ORDER BY NEWID()
>>>>
>>>>
>>>>where xxx is any number from 1 to ...
>>>>
>>>>I thought you want to SET values not to SELECT records
>>>
>>>Funny thing that I posted this solution long time ago here (don't recall where did I pick it, from tek-tips, I believe).
>>>
>>>Anyway, I want to insert about a million records and I want to somehow don't have the same values. What would be the best approach?
>>>
>>>BTW, I found that I only inserted about 10K records. Missed one zero in my counter, I guess.
>>
>>Yeah,
>>From tek-tips it is :-)
>>What you have as insert routine?
>
>Something simple like
>
>declare @counter int, @AddStr varchar(8)
>
>set @counter = 100000000000
>
>while @counter >5
>  begin
>   insert into Table1 values ('First' + @AddStr, ...)
>   insert into tabl2 values (@@IDENTITY, Here I want a random Symbol, Random Qty and an average price for that Symbol)
>  set @counter = @counter - 1
>end
I am not sure what Random Symbol means, something like this?
while @counter >5
  begin
   insert into Table1 values ('First' + @AddStr, ...)
   insert into tabl2 values (SCOPE_IDENTITY(), ????, CAST(RAND()*10000000 as int)/RAND())
   set @counter = @counter - 1
end
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform