2

I have a table with a uniqueidentifier column. What is the Default Value or Binding i should set in order for each new row to generate a new uniqueidentifier?

Setting the default to newid() always returns 00000000-0000-0000-0000-000000000000

EDIT: Apparently i got it all wrong, the insert was done from Entity Framework, and it doesn't handle this scenario.

Entity Framework - default values doesn't set in sql server table

Community
  • 1
  • 1
adrianvlupu
  • 4,188
  • 3
  • 23
  • 29
  • 3
    No, setting the column default to NEWID() definitely does work. Post your code so we can tell you what's wrong. – Jeroen Mostert Nov 19 '14 at 12:39
  • Consider using NEWSEQUENTIALID() instead of NEWID(). This will generate incremental values which can improve performance if the column is indexed, especially the clustered index. – Dan Guzman Nov 19 '14 at 13:17

1 Answers1

7

newid() should work.

See images below:

enter image description here

enter image description here

You have another issue there.

SmartDev
  • 2,802
  • 1
  • 17
  • 22