Why it's
select * from [User]
rather than:
select * from User
?
Another reason : Square brackets mainly used to identify the column names with spaces or special characters in them. e.g. [movie name]
However in that case, you must use brackets to refer to these columns then.
So in order to give the universal idea to be able to use single name and multiple names for fields, the [] are always shown in the syntaxes.
This could be the same reason behind applying [] to table name as well.
According to this post: "" and [] are delimeter identifiers. This is necessary if the column name/table name is a reserved keyword or contains special characters such as a space or hyphen.
And this reference says User
is a reserved keyword ...
You may want to try out with table name like myuser
, to confirm if this nature still persists.
One other thing, if your book is an old version, where [] were optional in Visual studio for single table names. However it may have changed to the earlier versions of Visual stduio where you must use square brackets at times independent of table name being single name, two names, reserved word, name with special characters... :)
I know where the problem is... table Name "Users" is ok instead of "User"
reference to: http://msdn.microsoft.com/en-us/library/aa224033(v=sql.80).aspx