Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Create unique GUIDs - need help
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Create unique GUIDs - need help

 Post Reply Post Reply Page  <12
Author
StarDust View Drop Down
Senior Member
Senior Member


Joined: 14 May 2007
Location: Bangladesh
Status: Offline
Points: 310
Post Options Post Options   Thanks (0) Thanks(0)   Quote StarDust Quote  Post ReplyReply Direct Link To This Post Posted: 14 August 2008 at 6:14am
Originally posted by dj air dj air wrote:

randoimise the sections being used like SECOND(NOW()), and Value = round(odd/Second)
and depending on that use different MOD 3 = 3 or others to create random


This way the whole ID will be unique, right? Or am I required to run a check?
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post Posted: 14 August 2008 at 8:39am
it will be random,
 
thinking on making it unique , most ways will require  a DB check, because any check may result in an other record.
 
its making enough veriables time is usually a good start point to make it random.
 
 
Back to Top
Jono View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 18 September 2006
Location: United Kingdom
Status: Offline
Points: 100
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jono Quote  Post ReplyReply Direct Link To This Post Posted: 16 August 2008 at 5:21pm
Originally posted by StarDust StarDust wrote:


Originally posted by Jono Jono wrote:

GUID's are special type of ID's and, as you've guessed, not exactly what you're after


So, are you trying to say that I can generate unique IDs without creating a GUID? How? Consider there will be performance issues.

Or, if it is impossible to generate unique IDs, is there a way to shorten the lenghth of a GUID? like, converting the GUID or some part of it to another value?

Your suggestion do helps me undertand where i am. Thank you very much for helping me through this and I look forward to get some more till I get a solution from you!Smile
 
Hi Stardust,
 
I understand a bit better what you're trying to achieve. So let's make it a bit simpler for ourselves. As DJ's said, you can create your own Unique ID's, but you'll have to check them. Autonumbers are already checked, but they are squential, and not what you're after.
 
So, were back on to GUID's - yes, i know this is where you started, sorry about that.
 
I'm going to assume you're going to use SQL2005 (in one version or another) rather than writing two versions of your code. Here are some links about generating GUIDs:
 
 
and finally WIKI ('cos it's always correct Smile): http://en.wikipedia.org/wiki/Globally_Unique_Identifier
 
The first link also shows some conversion options. Because the number is autogenerated, it's a 32 byte number and (i believe) the length cannot be changed. If you do want to represent it in a shorter fashion, you could try writing a routing to change the base.
 
For example hex is base 16 (0-9,A-F), but you could use base 36(0-9,A-Z) or some other base [base62 - 0-9,A-Z,a-z - this get more complicated!]. I did write a converter in Pascal as a college project, but that was ages ago!
 
I think the NEWID() function is the way forward for you, but let us know what you think.
 
Jono
Back to Top
Dan H View Drop Down
Newbie
Newbie


Joined: 17 September 2006
Location: United States
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dan H Quote  Post ReplyReply Direct Link To This Post Posted: 29 August 2008 at 8:58pm

Could it be as simple as grabbing the autonumber, and then stringing it with an alpha and a random? That way, even if the random came up twice- the autonumber would keep it unique.

Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.