如果 table 的名称包含数字字符,则无法从 table 获取数据

Can't get data from table if table's name have number character

我的 SQL Server 2014 Management Studio 有问题。

我创建了一个数据库,然后在其中创建了一个 table。我写了一个小演示来从 table 获取数据。但是如果我的 table 的名字没有数字(tablenamea,tablenameb,...),如果我在 [= 中插入 1 个或多个数字,我将无法获取数据25=]的名字(tablenamea1,tablenameb12,..),我可以得到数据。 (附上2张图片)

table 带编号的名字 https://social.technet.microsoft.com/Forums/getfile/619694 没有数字的名字 https://social.technet.microsoft.com/Forums/getfile/619695 没有数字

为什么?以及如何解决?

谢谢。

User 是一个 reserved keyword,请改用:

select * from [User]

或者考虑为您的 table 使用其他名称。

Although it is syntactically possible to use SQL Server reserved keywords as identifiers and object names in Transact-SQL scripts, you can do this only by using delimited identifiers.