Y
yui
Hi there,
I need to create unique primary keys in my tables but I don't care about the
format of these keys. They're used simply to identify the record and serve
as foreign keys in other tables (users never see them). I've always relied
on autoincrement keys for this in the past (normally stored as integers) but
now I see SQL Server has a "uniqueidentifier" type which is just a GUID by
default (apparently you can change this though). It's been a long time since
I've done any SQL Server programming so:
1) How exactly would I create an integer field that serves as an
autoincrement key (what do I set in VS which is where I'm managing my DB for
now)
2) Why would (or should) I use a "uniqueidentifier" instead of 1 above. If
an autoincrement key is incremented for each new record and will never be
reused (and my tables will never approach 2+ billion records), what's the
point of a "uniqueidentifier" in this case (if any). It just takes up extra
space and buys me nothing in return (compared to the smaller 32 bit integer)
Thanks in advance.
I need to create unique primary keys in my tables but I don't care about the
format of these keys. They're used simply to identify the record and serve
as foreign keys in other tables (users never see them). I've always relied
on autoincrement keys for this in the past (normally stored as integers) but
now I see SQL Server has a "uniqueidentifier" type which is just a GUID by
default (apparently you can change this though). It's been a long time since
I've done any SQL Server programming so:
1) How exactly would I create an integer field that serves as an
autoincrement key (what do I set in VS which is where I'm managing my DB for
now)
2) Why would (or should) I use a "uniqueidentifier" instead of 1 above. If
an autoincrement key is incremented for each new record and will never be
reused (and my tables will never approach 2+ billion records), what's the
point of a "uniqueidentifier" in this case (if any). It just takes up extra
space and buys me nothing in return (compared to the smaller 32 bit integer)
Thanks in advance.