views:

513

answers:

2

I have a uniqueidentifier column in a table and it's not a key or index. I want to set the default value using NEWSEQUENTIALID(), but I get the error:

Error validating default for column..

But if I use NEWID() no error. What's going on?

A: 

Hi, according to the documentation: http://msdn.microsoft.com/en-us/library/ms189786.aspx Remarks section:

... When NEWSEQUENTIALID() is used in DEFAULT expressions, it cannot be combined with other scalar operators. For example, you cannot execute the following:

CREATE TABLE myTable (ColumnA uniqueidentifier DEFAULT dbo.myfunction(NEWSEQUENTIALID())) ...

Does that answer your question?

radekg
No, I am using NEWSEQUENTIALID() by itself in the default field in the table designer in sql server management studio. NEWID() works however and I just wanted to know why.
P a u l
I see what you mean, I just tested that and when setting NEWSEQUENTIALID() as the default value in SSMS 2008 I get an error but following SQL "CREATE TABLE [dbo].[Table_1]([col1] [int] NOT NULL, [uuid] [uniqueidentifier] NOT NULL DEFAULT (NEWSEQUENTIALID())) ON [PRIMARY]" executes just fine and there is no error while editing the table later on. Looks like an SSMS bug methinks.
radekg
+1  A: 

This is a bug in the designer that is not being fixed by microsoft.

http://social.msdn.microsoft.com/Forums/en-US/sqltools/thread/cad8a4d7-714f-44a2-adb0-569655ac66e6

P a u l

related questions