O'Reilly logo

Microsoft® SQL Server 2008 R2 Unleashed by Alex T. Silverstein, Chris Gallelli, Paul Bertucci, Ray Rankins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Optimizer Hints

You can specify three types of hints in a query to override the decisions made by the Query Optimizer:

• Table hints

• Join hints

• Query hints

The following sections examine and describe each type of table hint.

Forcing Index Selection with Table Hints

In addition to locking hints that can be specified for each table in a query, SQL Server 2008 allows you to provide table-level hints that enable you to specify the index SQL Server should use for accessing the table. The syntax for specifying an index hint is as follows:

SELECT column_list FROM tablename WITH (INDEX (indid | index_name [, ...]) )

This syntax allows you to specify multiple indexes. You can specify an index by name or by ID. It is recommended that you specify ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required