April 24, 2007 at 1:20 pm
Greetings,
Why does the Query window require me to bracket a view named 1vw_MyView when selecting from it (i.e. select * from [1vw_MyView]). If I don't put brackets around it I get the following error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '.1'.
If I create the same view and name it without the initial "1" (i.e. vw_MyView), it returns just fine without the syntax error. Is there a limitation on naming views beginning with a number? Thanks.
April 24, 2007 at 1:31 pm
Mostly, because it's just not allowed... read the following from Books Online...
The rules for the format of regular identifiers are dependent on the database compatibility level, which can be set with sp_dbcmptlevel. For more information, see sp_dbcmptlevel. When the compatibility level is 80, the rules are:
Certain symbols at the beginning of an identifier have special meaning in SQL Server. An identifier beginning with the "at" sign denotes a local variable or parameter. An identifier beginning with a number sign denotes a temporary table or procedure. An identifier beginning with double number signs (##) denotes a global temporary object.
Some Transact-SQL functions have names that start with double at signs (@@). To avoid confusion with these functions, it is recommended that you do not use names that start with @@.
When used in Transact-SQL statements, identifiers that fail to comply with these rules must be delimited by double quotation marks or brackets.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 24, 2007 at 3:23 pm
Thanks Jeff. I figured that it was a rule in the RDBMS, but couldn't find documentation on why. BOL explains it. Thanks for the quick reply.
April 28, 2007 at 9:59 pm
why on earth would you want to name your objects like that? that's very non-standard.
---------------------------------------
elsasoft.org
May 2, 2007 at 8:20 am
Wouldn't necessarily name objects this way. I was just wondering why this limitation exists in SQL Server. Oracle doesn't have this problem.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply