Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error setting newsequentialid() default in sql server 2008

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?

EDIT: you can just ignore the error dialog and continue.

like image 509
P a u l Avatar asked Jun 18 '09 23:06

P a u l


1 Answers

Quoting accepted answer of this question.

Workaround: create your table without specifying any default, and then type in this T-SQL statement in a normal query window and run it:

ALTER TABLE dbo.YourTable
    ADD CONSTRAINT DF_SerialID DEFAULT newsequentialid() FOR SerialID
like image 92
programmer Avatar answered Oct 17 '22 02:10

programmer