Export (0) Print
Expand All

OPTION Clause (Transact-SQL)

Specifies that the indicated query hint should be used throughout the entire query. Each query hint can be specified only one time, although multiple query hints are permitted. Only one OPTION clause can be specified with the statement.

This clause can be specified in the SELECT, DELETE, UPDATE and MERGE statements.

Topic link icon Transact-SQL Syntax Conventions

[ OPTION ( <query_hint> [ ,...n ] ) ] 

query_hint

Keywords that indicate which optimizer hints are used to customize the way the Database Engine processes the statement. For more information, see Query Hints (Transact-SQL).

The following example shows how the OPTION (GROUP) clause is used with a GROUP BY clause.

USE AdventureWorks2012;
GO
SELECT ProductID, OrderQty, SUM(LineTotal) AS Total
FROM Sales.SalesOrderDetail
WHERE UnitPrice < $5.00
GROUP BY ProductID, OrderQty
ORDER BY ProductID, OrderQty
OPTION (HASH GROUP, FAST 10);
GO

Community Additions

ADD
Show:
© 2014 Microsoft