Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 29th, 2008, 01:47 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default Is uniqueidentifier is always unique ?

Hi All,

Is uniqueidentifier is always unique ?

e.g I have a database named "mydatabse" ,where there are 7 table with uniqueidentifier are set to the Primary key Columns.They have default newid() that creates unique identifier for those primary key columns.

Now in one of my SP i have created temp table like

DECLARE @UserProfile table(NewKeyID uniqueidentifier,UserGUID varchar(36), UserName varchar(50))
insert into @UserProfile values(newid(),'A1','B1');
insert into @UserProfile values(newid(),'A2','B2');
insert into @UserProfile values(newid(),'A3','B3');
insert into @UserProfile values(newid(),'A4','B4');

select * from @UserProfile

Now "NewKeyID" which is unique identifier column will always have a unique value??(and it will not match with the other primary key column value)??

Any input or pointer would be a great help!!

Cheers :)

vinod
__________________
Cheers :)

vinod
 
Old May 29th, 2008, 06:49 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

As near as I can remember the GUID in SQL Server is based off of the MAC address of the NIC and the current system time so yes the GUID *should* always be unique. (I believe there is some mathmatical inprobablity whereby you can wind up with a duplicate guid but the chances are so low it isn't worth worrying about)

To this end I see nothing wrong with the structure you have shown in your post, in fact I am currently working in a system where we employ this very same technique and have not had an issue with it thus far.

hth.
-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old May 30th, 2008, 03:05 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

They used to be created from MAC but no longer. They are supposed to unique in space and time but there's always the chance that two are created the same and the they are also both used in your application. According to quantum physics there's also the chance that a cold cup of water can start to boil without being externally heated, both events are about as equally unlikely.

--

Joe (Microsoft MVP - XML)
 
Old May 30th, 2008, 05:53 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Thank you Doug and Joe..



Cheers :)

vinod
 
Old May 30th, 2008, 11:31 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
quote:According to quantum physics there's also the chance that a cold cup of water can start to boil without being externally heated, both events are about as equally unlikely.
Hahaha, thanks for that. I am sure that will come in handy if I have to explain the same question to someone...

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Use of UNIQUEIDENTIFIER ggandta BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 2 March 9th, 2007 01:52 PM
Unique Records arholly Access 9 December 14th, 2006 08:22 AM
Two unique Attribues shumba XML 5 February 28th, 2006 09:05 PM
Unique Problem rekha_jsr Classic ASP Basics 0 December 10th, 2005 12:21 AM
Uniqueidentifier to Integer Conversion mp01 BOOK: Beginning VB.NET Databases 2 August 8th, 2005 06:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.