| How to
use UNION ALL instead of or? |
|
The following
sample demonstrates the use of UNION ALL. Index usage is usually
better with UNION ALL:
use Northwind
go
select CompanyName, ContactName, ContactTitle, Phone from Customers
where Country='Canada'
union all
select CompanyName, ContactName, ContactTitle, Phone from Customers
where Region='Quebec'
union all
select CompanyName, ContactName, ContactTitle, Phone from Customers
where City='Montreal'
|
| The World Leader
in SQL Server Training |
|