mehdi lotfi
mehdi lotfi

Reputation: 11571

SQL Server Default value for columns

When you use default value for a column in SQL Server Management Studio table designer, SSMS change your default and stand Parenthesis around of that (In all editions and all versions of SQL Server). For example if you set 0 as default value, this default changed to (0). I don't know why sql server use parenthesis, and is there a practical reason.

Thanks in advance.

Upvotes: 3

Views: 714

Answers (2)

Hamed Kamrava
Hamed Kamrava

Reputation: 12847

Actually, 0 and (0) will evaluate to the same result, so there is nothing to really overcome. Ignore it. It's just how SQL stores them internally and a visibility issue. It does that is you do it interactively as well. Not sure why does this , but not to worry.

Upvotes: 1

Damien_The_Unbeliever
Damien_The_Unbeliever

Reputation: 239636

There are certain types of objects, such as DEFAULTs and CHECK constraints that SQL Server doesn't store the original, textual form of - in contrast with, say, stored procedures, where you can (absent encryption) always retrieve it in the exact form you gave it to the server - complete with any white space, formatting, comments, etc.

Because SQL Server doesn't store the textual form, it always has to re-generate textual forms to show to users when they ask for such objects. When and where it chooses to insert parentheses can be a bit of a mystery (it's not documented) but since they don't change the meaning of the expression, they shouldn't be a concern.

Upvotes: 3

Related Questions