Applies To: SQL Server 2014, SQL Server 2016 Preview
Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).
Combines two conditions. When more than one logical operator is used in a statement, OR operators are evaluated after AND operators. However, you can change the order of evaluation by using parentheses.
Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database, Azure SQL Data Warehouse Public Preview.
The following example uses the vEmployeeDepartmentHistory view to retrieve the names of Quality Assurance personnel who work either the evening shift or the night shift. If the parentheses are omitted, the query returns Quality Assurance employees who work the evening shift and all employees who work the night shift.
USE AdventureWorks2012; GO SELECT FirstName, LastName, Shift FROM HumanResources.vEmployeeDepartmentHistory WHERE Department = 'Quality Assurance' AND (Shift = 'Evening' OR Shift = 'Night');
Here is the result set.
FirstName LastName Shift
------------ ---------------- -------
Andreas Berglund Evening
Sootha Charncherngkha Night