GregD February 2016

Invalid object name in SQL Join

I am switching to SQL Server from the visual editor approach I used in MS Access. Here is my first attempt. I am joining two tables and keep getting an invalid object. Where am I going wrong? The error message specifically says:

(560180 row(s) affected)
Msg 208, Level 16, State 1, Line 20
Invalid object name 'BillingTable'.

My query is:

SELECT [Tracking_Number]
      ,[Package_Key]
      ,[Manifest_Datetime]
      ,[Packed_Datetime]
      ,[Order_Number]
      ,[WMS_Order_Number]
      ,[Shipped_Warehouse_Name]
      ,[Carrier]
      ,[Service_Name]
      ,[Zone]
      ,[Estimated_Weight]
      ,[Estimated_Cost]
      ,[Preferred_Warehouse_Name]
      ,[WMS_Shipping_Method_Name]
  FROM [Shipping].[dim].[tbl_Package] as PackageTable

  where [Manifest_Datetime] > '1/1/2016'

  SELECT [Invoice_Date_Key]
      ,[Order_Date_Key]
      ,[Package_Key]
      ,[Billed_Weight]
      ,[Billed_Weight_Metric]
      ,[Package_Quantity]
      ,[Total_Cost_Dollars]
      ,[Tax_Cost_Dollars]
      ,[Total_Cost_Billed_Currency]
  FROM [Shipping].[fact].[tbl_Shipping_Billing] as BillingTable

  JOIN BillingTable
  on PackageTable.Package_Key = BillingTable.Package_Key

Answers


Wyatt Shipman February 2016

Your query should look like this:

Select PackageTable.*, BillingTable.*
From [Shipping].[dim].[tbl_Package] as PackageTable
Inner Join [Shipping].[fact].[tbl_Shipping_Billing] as BillingTable
on PackageTable.Package_Key = BillingTable.Package_Key
where PackageTable.[Manifest_Datetime] > '1/1/2016'

You can call out the specific fields you want from those tables instead of using the .*

Post Status

Asked in February 2016
Viewed 3,860 times
Voted 13
Answered 1 times

Search




Leave an answer