Tip Of The Day
- Create a primary key on each table you create and unless you are really knowledgeable enough to figure out a better plan, make it the clustered index (note that if you set the primary key in Enterprise Manager it will cluster it by default).
- Create an index on any column that is a foreign key. If you know it will be unique, set the flag to force the index to be unique.
- Don’t index anything else (yet).
- Unless you need a different behaviour, always owner qualify your objects when you reference them in TSQL. Use dbo.sysdatabases instead of just sysdatabases.
- Use set nocount on at the top of each stored procedure (and set nocount off) at the bottom.
- Think hard about locking. If you’re not writing banking software, You can use the NOLOCK hint, but it’s often easier to use SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED at the top of the procedure, then reset to READ COMMITTED at the bottom.
- I know you’ve heard it a million times, but only return the columns and the rows you need.