Listing 1: Creating 3 Tables and Running a Test Query USE AdventureWorks; GO IF EXISTS (SELECT 1 FROM sys.tables WHERE name = 'OrderHeader') DROP TABLE OrderHeader; GO SELECT * INTO dbo.OrderHeader FROM Sales.SalesOrderHeader; GO IF EXISTS (SELECT 1 FROM sys.tables WHERE name = 'Territory') DROP TABLE Territory; GO SELECT * INTO dbo.Territory FROM Sales.SalesTerritory; GO IF EXISTS (SELECT 1 FROM sys.tables WHERE name = 'Customers') DROP TABLE Customers; GO SELECT * INTO dbo.Customers FROM Sales.Customer; GO SELECT SalesOrderID, OrderDate, Status, h.CustomerID, c.AccountNumber, Name as Territory, CountryRegionCode as CountryRegion FROM OrderHeader h JOIN Customers c ON h.CustomerID = c.CustomerID JOIN Territory t ON c.TerritoryID = t.TerritoryID WHERE c.TerritoryID = 2; GO 1