|
Home > Archive > microsoft.public.cert.mcdba > March 2003 > 70-229:uniqueidentifier
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
70-229:uniqueidentifier
|
|
|
| For a column with the following definition:
LogID uniqueidentifier DEFAULT (NEWID())
The Readiness Review says that it is Nullable and
Updatable. My questions are:
1. with a default definition, this column will never ne
NULL. Why it is Nullable?
2. as a uniqueidentifier column how can you update it?
Will appreciate any help.
Janie
| |
|
| "janie" <jzhao@tarrantcounty.com> wrote in message
news:052901c2ea68$a71fe960$300
1280a@phx.gbl...
> For a column with the following definition:
>
> LogID uniqueidentifier DEFAULT (NEWID())
>
> The Readiness Review says that it is Nullable and
> Updatable. My questions are:
> 1. with a default definition, this column will never ne
> NULL. Why it is Nullable?
Well, without more information, it *may* be nullable. It gets the default
NULL/NOT NULL setting since it's not specified, and the default is
configurable. Rather than learn the default (and I think the SQL default is
the opposite of the ANSI default) or rely on this setting, it's wise to
always specify.
But, assuming NULL is the default, you can still explicitly supply a value
of NULL:
INSERT ThatTable(LogID) VALUES(NULL)
UPDATE can do the same thing. You're right that it won't be NULL without a
little effort, but it is still nullable.
> 2. as a uniqueidentifier column how can you update it?
There's nothing special required at all.
UPDATE ThatTable
SET LogID = '1234-4567890-etc'
In fact, I think this is the most useful application of this data type. It's
similar to IDENTITY, but since every client can reliably generate unique
values on its own, it won't have to requery the database to find out what
value has been assigned. Or fiddle with @@IDENTITY and other identity
retrieval functions to embed in further commands. The client can very simply
embed the generated ID in a full query.
|
|
|
|
|