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