Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 How would I randomize SQL Server db Identity field
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 07 January 2005 :  21:28:56  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message
^^ title... In MS Access I have the option to "increment" or "randomize"... I was wondering how I would have sql server randomize an auto-identity field.

-Stim

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 08 January 2005 :  09:19:06  Show Profile
you can set the start number and increment, don't think you can randomize?

The UK MkIVs Forum
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 08 January 2005 :  09:50:52  Show Profile  Send ruirib a Yahoo! Message
You'd need to use a ROWGUID column, but it's a bit more complex than using an identity one.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 08 January 2005 :  14:23:09  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message
quote:
Originally posted by ruirib

You'd need to use a ROWGUID column, but it's a bit more complex than using an identity one.



I'll google it, but could you give me more info on this?

-Stim
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 08 January 2005 :  15:20:40  Show Profile  Send ruirib a Yahoo! Message
Ok, here is what you can do.
You will probably need to create a new column for your identifier. When doing it from Enterprise Manager, choose uniqueidentifier for the column type. When you do that, EM will set the default value for the column to be the newid() T-SQL function. Then set the Is RowGuid property to Yes and you will be set. Use EM to define the column as the primary key column.

With this you will have 16 bit generated values for your column that are guaranteed to be unique.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 08 January 2005 :  17:09:28  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message
Thx ruirib, I'll play around with it

-Stim
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.36 seconds. Powered By: Snitz Forums 2000 Version 3.4.07