Solution for database table names at the beginning of SQL Server number _mssql

Source: Internet
Author: User

Today I have a depressing question about the database table name.

The table name of a SQL Server database can begin with a number, but you cannot write the table name directly when you query, as follows:

SELECT *
Form 1_tablename

In the course of execution, the error is not correct. But add brackets to the table name, and you can do it as follows:

SELECT *
from [1_tablename]

When developed with a dataset in VS, an SQL statement is automatically generated, but some of the generated SQL statements are added with square brackets, but some are not added,

In the process of program execution, it is not possible to determine the correctness of the statement, and in the debugging process, it is not easy to find errors.

So in the process of writing SQL statements in the future, we must standardize, table name is best not to start with numbers.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.