Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server - OPTION CLAUSE

Tags:

sql

sql-server

Can someone tell me if the OPTION clause is available in SQL Server 2012.

I cannot see any documentation to see when it was introduced.

I want to use OPTION (LOOP JOIN) on a SQL Server 2012 database...

Thanks

like image 223
Chris Avatar asked Jul 25 '26 11:07

Chris


1 Answers

As Gordon Linoff stated, yes - the option (loop join) is available in SQL 2012.

I spun up a new SQL Database in Azure, changed the compatibility level to 110 (SQL 2012), and ran two queries. Screen shot of both execution plans shown as well.

select * from saleslt.customer c
inner join SalesLT.CustomerAddress ca
    on c.CustomerID = ca.CustomerID

select * from saleslt.customer c
inner join SalesLT.CustomerAddress ca
    on c.CustomerID = ca.CustomerID
OPTION (LOOP JOIN);

Loop Join Execution Plan

As stated by others, I also usually don't force hints but answering your question as stated: Yes, it is available.

like image 133
LaraRaraBoBara Avatar answered Jul 28 '26 05:07

LaraRaraBoBara



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!