HOWTO: Generate Random Column ID as the Default 
Author Message
 HOWTO: Generate Random Column ID as the Default
I have a column in a SQL table that needs to have a random number stored in
it upon an INSERT operation. I'd like to use the DEFAULT VALUE attribute for
the column definition.

I also need a DEFAULT VALUE for a column that gets the maximun number in the
column and adds 1 to it. My first thought on this one, is SELECT
MAX(column_name)+1 FROM TABLE, but I want to used the DEFAULT VALUE
attribute as well.

Are there any rock solid routines for these two DEFAULTS?

--
Thank you,

Dan Sikorsky MSCS, BSCE, BAB



Sun, 26 Dec 2004 00:14:58 GMT
 HOWTO: Generate Random Column ID as the Default

Why can't you use an IDENTITY COLUMN?

- Anith


Quote:
> I have a column in a SQL table that needs to have a random number stored
in
> it upon an INSERT operation. I'd like to use the DEFAULT VALUE attribute
for
> the column definition.

> I also need a DEFAULT VALUE for a column that gets the maximun number in
the
> column and adds 1 to it. My first thought on this one, is SELECT
> MAX(column_name)+1 FROM TABLE, but I want to used the DEFAULT VALUE
> attribute as well.

> Are there any rock solid routines for these two DEFAULTS?

> --
> Thank you,

> Dan Sikorsky MSCS, BSCE, BAB



Sun, 26 Dec 2004 02:50:54 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. How to Generate True Random IDs?

2. Generate random password as default value

3. Need to generate a random ID

4. generate random unique object id

5. Generate Key(ID) column on the fly

6. Changing default column widths generated by DTS import wizard

7. ODBC: SELECT Column Id from COMPUTE Column Id?

8. Selecting the first 6 columns of a table by column order/ column id

9. HOWTO: Select distinct records with multiple columns based on one column

10. Howto select all columns without the identity column?

11. HOWTO - Random character generation for primary key

12. HOWTO - Random character generation for primary key


 
Powered by phpBB® Forum Software