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.
| Author |
Topic |
|
sql777
Constraint Violating Yak Guru
314 Posts |
Posted - 2004-04-06 : 16:36:10
|
| Hi,If I have a GUID (stripped of the {} and -) so that its only 32 characters long, I can create a column in the db as char(32).I would also make that colomn a unique key. Do you guys see this as 1) the same 2) better 3)worse than having a UNIQUEIDENTIFIER key in the db? |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2004-04-06 : 17:06:53
|
| Maybe.Why are you using a GUID as a key in your table? For replication purposes? If not, this could be overkill if not a performance killer. If you're going to use a GUID as the Primary Key, then I hope you have also created a CLUSTERED INDEX on some other field, otherwise you're likely to see a lot of page splits when new rows are inserted if the clustered index is on the GUID.--------------------------------------------------------------Find more words of wisdom at [url]http://weblogs.sqlteam.com/markc[/url] |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-04-06 : 19:14:08
|
| And if you are using it for replication, you could break the replication by changing the GUID, so I would use the UNIQUEIDENTIFIER.If you aren't doing replication, use the natural key as your primary key or use an identity column. The identity column takes up way less space.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-04-07 : 00:15:25
|
| And FYI, a GUID is actually 16 bytes long, it is only displayed as 32 characters. Using a char(32) would double your storage space. |
 |
|
|
|
|
|