Sometimes the SQL Server query optimizer does not pick the best index to use in a join operation. This can be caused by a multitude of factors (out of date statistics, wrong indexing strategy for a table, etc) ... for what ever reason it happens, there is a way to force SQL Server to pick the correct...
Today I had to do a common task that I've done several times, but suddenly realized I should put up here, because its a fairly common issue. Say you have TableA has a one to many relationship to TableB, and you want all of the values in TableB.dbo.ColumnA to be in a csv list based on the FK. This...
Unless otherwise specified when you create your tables primary key in SQL Server 2000, 2005 and 2008 will have a clustered index on it. This will be a good default choice if you are going to be joining other tables together on this value. If you are going to be joining or selecting based on another value...
By default, when you create a primary key column in SQL Server, it makes it a clustered index. Sometimes this will be a default advantage, sometimes a serious disadvantage for performance as clustered indexes are the cornerstone of performance tuning in SQL Server. In the event that a clustered primary...
In the world of RDBMS' you may hear the term "table scan" thrown around, this is a term used to describe an event that occurs when you search for data in a table, and your query either doesn't take advantage of an existing index, or there is no index on the table. Generally, a table...