T-SQL

CREATE TABLE syntax surprise

What do you think: Is this valid CREATE TABLE statement?

CREATE TABLE dbo.SampleTable (ID INT,)
GO

Definitely yes! Try it by your own.

The only one reason how to explain I see that after comma there can be 0 or n members (empty) collection of constraints like in this sample:

CREATE TABLE dbo.SampleTable (ID INT NOT NULL, PRIMARY KEY(ID))
GO

 

Leave a Reply

Your email address will not be published. Required fields are marked *