Home Ask Login Register

Developers Planet

Your answer is one click away!

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]
  FROM [Shipping].[dim].[tbl_Package] as PackageTable

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

  SELECT [Invoice_Date_Key]
  FROM [Shipping].[fact].[tbl_Shipping_Billing] as BillingTable

  JOIN BillingTable
  on PackageTable.Package_Key = BillingTable.Package_Key


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


Leave an answer

Quote of the day: live life