Add 'Guid' column with NewId() as default value, does not work properly

4.9k Views Asked by At

I have to add a column called 'Guid' that should be have default value. It's not primary-key. So, I did it as below:

ALTER TABLE myTable ADD [Guid] uniqueidentifier NOT NULL DEFAULT(NewId())

Ok, now I have a column that has acceptable value. But after insertion a new row, the Guid column's value is

00000000-0000-0000-0000-000000000000

I tested it with another name:

ALTER TABLE MyTable ADD Guids uniqueidentifier NOT NULL DEFAULT(NewId())  

and there is no problem with this. It seems that the main problem is the name of column (Guid), maybe. Is that true? So, How can I fix that, since I can't use another name for it.

0

There are 0 best solutions below