Format SQL Code. Make it readable. Wrap it.
Use Column name in ORDER BY clause instead of numbers.
Do not use TEXT or NTEXT if possible. In SQL Server 2005 use VARCHAR(MAX) or NVARCHAR(MAX).
Join tables in order that they always
perform the most restrictive search first to filter out the maximum
number of rows in the early phases of a multiple table join.
Remember to SET NOCOUNT ON at the
beginning of your SQL bataches, stored procedures, triggers to avoid
network traffic. This will also reduct the chances of error on linked
server.
Do not use temp tables use CTE or Derived tables instead.
Always take backup of all the data.
Never ever work on production server
Do not use SELECT *, use proper column names to decrease network traffic and fewer locks on table.
Avoid Cursors as it results in performance degradation. Sub Query, derived tables, CTE can perform same operation.
Reduces the use of nullable columns.
NULL columns consumes an extra byte on
each column used as well as adds overhead in queries. Also NULL is not
good for logic development for programmers.
Use User Defined Functions sparsely, use Stored Procedures instead.
Stored Procedure can achieve all the tasks UDF can do. SP provides much more features than UDFs.
Do not prefix stored procedure with SP_ prefix. As they are first
searched in master database, before it is searched in any other
database.