O'Reilly logo

Microsoft® SQL Server™ 2000 Programming by Example by Carlos Eduardo Rojas, Fernando G. Guerrero

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

Using Hints

In some cases, you might think that there is a better way to execute your queries than the query plan selected by the Query Optimizer. SQL Server 2000 provides several optimizer hints to tailor the execution to your needs.

You can specify the type of join to execute by using the LOOP, HASH, MERGE, or REMOTE hints of the JOIN clause. The query in Listing 11.23 forces a LOOP join to connect the Orders and Order Details tables, a MERGE join between the Products and Order Details table, and a HASH join to connect the Categories and Products tables. The purpose of this example is to show how to use the optimizer hints; the output is the same you can have without using these optimizer hints.

Note

Joins were covered in Chapter 5. The REMOTE ...

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