Why does SSMS table designer put () around default value
I create a table using table designer. I add a default of newsequentialid() to a column. Save the table, then open the table in the designer again and the default of the column is now (newsequentialid()). For some reason SSMS put round braces around the default. If i try to save any changes to the table it will error out saying i don't have a valid default for the column. I then have to click on the column and change (newsequentialid()) to newsequentialid().
It's odd. There's no sign of parentheses in the syntax spec for CREATE TABLE. It just says '[ CONSTRAINT constraint_name ] DEFAULT constant_expression ]'. Most examples you see have parentheses around the default value and I've always thought that was unnecessary noise. I'm guessing the scripting engine adds them because it could be a complex expression which might make the query confusing to read. (Or possibly even do the wrong thing when run?) Interestingly though, I don't see any problems with these extra parentheses. For example, this runs fine on my SQL 2014 Developer Edition: create table x ( ID uniqueidentifier not null constraint DF_xID default (newsequentialid()) );