Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Assigning Primary Keys

0 views
Skip to first unread message

Keith Flaspoehler

unread,
Apr 22, 2002, 10:26:06 AM4/22/02
to
How and when are primary keys assigned values? In my table, I've got a
field CompNo set up as a uniqueidentifyer field type. Does SQL server
automatically populate this field or do I need to assign a value for this in
VB before I attempt to write the record?

Thanks,

Keith Flaspoehler


BP Margolin

unread,
Apr 22, 2002, 11:41:57 AM4/22/02
to
Keith,

Check out the T-SQL NewID ( ) function in the SQL Server Books Online. This
function generates a GUID, and you can either call it explicitly or use it
as a DEFAULT constraint in the table definition.

-------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.

"Keith Flaspoehler" <kfl...@mindspring.com> wrote in message
news:aa16h5$h0p$1...@nntp9.atl.mindspring.net...

--CELKO--

unread,
Apr 22, 2002, 1:38:44 PM4/22/02
to
>> How and when are primary keys assigned values? <<

Key are assigned BEFORE something is put into the database and the
methods vary, depending on your business rules. And they are not
"assigned" so much as "discovered"

>> In my table, I've got a field [sic] CompNo set up as a
uniqueidentifyer field [sic] type. Does SQL server automatically
populate this field [sic] or do I need to assign a value for this in


VB before I attempt to write the record? <<

SQL uses columns and not fields; fields are a file system concept,
like records. BIG difference. The whole idea of a uniqueidentifyer
is not just proprietary, it is non-relational. Can you tell what the
LOGICAL meaning of this uniqueidentifyer is in your data model? And
how you verify each uniqueidentifyer vlaue against reality?? You
aren't going to find it stamped onthe bottom of everythign in cration.
There is no check digit.

Plese read a book on data modeling. You are getting ready to set up a
disaster.

0 new messages