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

Syntax

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

Arguments

  • 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).

Examples

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

See Also

Reference

Hints (Transact-SQL)

SELECT (Transact-SQL)

UPDATE (Transact-SQL)

MERGE (Transact-SQL)

DELETE (Transact-SQL)