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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 GUID vs varchar

Author  Topic 

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2004-12-10 : 04:29:25
I just thought of something: instead of storing GUIDs in the database as uniqueidentifiers wouldn't it be better to store them as varchar? Or am I way off here? If one makes sure to validate that it actually is a guid before inserts, wouldn't you save alot of disk space? I must admit I have never really understood completely how this "length" attribute works...

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-12-10 : 04:40:52
Not so save space.
uniqueidentifier: 16 bytes
varchar(36): 36 bytes
Do You mean DATALENGTH ?

rockmoose
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2004-12-10 : 05:32:30
Now that's why I felt sort of silly asking the question. Since a GUID is actually 36 charaters and not 16 I assumed that it was sort of like a pointer to some other place like with the text datatype. But only now I realised that a GUID consists of hex-values and they are two characters each. One byte per hex then, eh?



--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-12-10 : 06:16:20
Each byte(8bits) stores 2 hexadecimal(4bits) values(0-F).

rockmoose
Go to Top of Page
   

- Advertisement -