Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
verybrightstar
Starting Member
16 Posts |
Posted - 2006-06-06 : 21:27:53
|
| hi all,i have a table called Order , the total no of total items in the Order table is 8000how can i create a random number from 1 - 8000 to insert into the temp tabledeclare @count as intselect @count = count(*) from Orderprint @countcreate table #temp1 (id int , RNID int)select CAST(Rand() * @count as int) as rnd from Order insert into #temp1select * from #temp1drop table #temp1kt |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-06 : 21:39:54
|
[code]insert into #temp1(id, RNID)select id, (abs(convert(int, convert(varbinary, newid()))) % 8000) + 1from Order[/code] KH |
 |
|
|
verybrightstar
Starting Member
16 Posts |
Posted - 2006-06-06 : 22:28:54
|
ok thanksquote: Originally posted by khtan
insert into #temp1(id, RNID)select id, (abs(convert(int, convert(varbinary, newid()))) % 8000) + 1from Order KH
kt |
 |
|
|
|
|
|