Christian Buettner-167247 (5/16/2012)
Hm, I am a little confused because of the missing comma before the CONSTRAINT declaration. That does not seem to be required based on a first test. But I checked my BOL to see verify the syntax, and this is what I found (excerpt):
( { <column_definition> | <computed_column_definition>
| <column_set_definition> }
[ <table_constraint> ] [ ,...n ] )
I cannot derive any meaning from that. Can anyone interpret this notation?
Anyways, it looks like the web contains an updated version of the syntax which makes more sense:
( { <column_definition> | <computed_column_definition>
| <column_set_definition> | [ <table_constraint> ] [ ,...n ] } )
http://msdn.microsoft.com/en-us/library/ms174979(v=sql.105).aspx
However this doesnt explain why it is possible to add the table constraint without a comma between the last column specification and the constraint itself.
Any ideas?
Chris, as far as I know, a constraint that follows a column definition without seperating column is considered a column constraint. But a column constraint should not reference any column.
I have not tested if the code as posted would actually work or complain about the column reference in the column constraint. If it does work, I would classify it as a parser bug, since the description in BOL implies that the seperating column between columns and table constraints is mandatory.