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 |
Staryon
Starting Member
10 Posts |
Posted - 2003-03-14 : 17:29:51
|
HiI need to create by code an autoincrement field. I know that I can do it using this:Alter table MyTable Alter column MyColumn AutoIncrement(1, 1)The problem is that I want the values of the column to be randomly generatedinstead of sequential.I have tried with things like "Alter column MyColumn AutoIncrement(random)"but doesn't work.Does anybody know how to do it?Thanks |
|
KnooKie
Aged Yak Warrior
623 Posts |
Posted - 2003-03-18 : 11:22:58
|
Why not forget using an AutoIncrement field and just use a Long Integer instead. Count the number of records you want to generate random numbers for ? Generate a random sequence up to this total and bung them into the integer column one by one.===========Paul |
 |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-03-18 : 11:57:57
|
Set a default value for the column equal to rnd(1)*100000 or something like.Hopefully you realize there is no guarantee that this column will be unique by generating random numbers ...- JeffEdited by - jsmith8858 on 03/18/2003 11:58:47 |
 |
|
|
|
|