A collection of SQL Server errors that programmers can easily ignore

Source: Internet
Author: User

1. Case all keywords in the uppercase T-SQL language are capitalized, specification requirements. 2. use ";"

Use ";" As a Transact-SQL statement terminator. Although a semicolon is not required, it is a good practice to use it, and you must add ";" to the end of the merge statement. (except for CTE table expressions)

3. Data type

Avoid using ntext, text, and image data types, substituting nvarchar (max), varchar (max), and varbinary (max)

Subsequent versions will cancel the ntext, text, and image of the three types

4. Query criteria do not use computed columns

For example year (createdate) = 2014, replace with createdate>= ' 20140101 ' and createdate<= ' 20141231 '.

5. The field is not allowed to be null when the table is built

Find a lot of people do not pay attention to this when building the table, in the next work when you need to query the data when you often need to add a condition in the where conditions are not NULL, such a condition not only increases the additional overhead, but also has a great impact on the performance of the query, It's possible that because of the more this query condition causes your query to become very slow, and the more important question is that allowing empty data can cause inaccurate query results.

5. Avoid using COUNT (*) When grouping statistics

6. Sub-query tables plus table aliases

7. Be sure to make a field query when querying

8. Predicate type to be aligned with the field type

9. Order of conditional fields

Original address: http://www.phpxs.com/post/2930

A collection of SQL Server errors that programmers can easily ignore

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.