Fixing the error: The multi-part identifier … could not be bound in Join statements

One of the most common errors that you might face in join statements is this error:

Msg 4104, Level 16, State 1, Line …

The multi-part identifier …… could not be bound.

The main reason for this error is that the source table cannot be found, for example if you have statement such as Table1.OrderDate, and then if you get error above, this means that Table1 cannot be found in the query. Sometimes you can see that source table exists in the query, but T-SQL cannot understand it, especially when you write join statements.

Consider join statement below:

select * from sales.SalesOrderHeader SH

left outer join sales.SalesOrderDetail SD

left outer join Production.Product P

on SD.ProductID=p.ProductID and SH.SalesOrderID=SD.SalesOrderID

With statement above you will get the error :

the reason is that SalesOrderHeader (SH) table is hidden from the third part of the join. and if you want to apply joining condition it will throw the error.

Resolution is:

put join condition of each join statement exactly after it. query below is showing fixed version of that statement:

select * from sales.SalesOrderHeader SH

left outer join sales.SalesOrderDetail SD

on SH.SalesOrderID=SD.SalesOrderID

left outer join Production.Product P

on SD.ProductID=p.ProductID

This statement used SH.SalesOrderID = SD.SalesOrderID right after the first join where the SH table is totally visible.

Reza Rad on FacebookReza Rad on LinkedinReza Rad on TwitterReza Rad on Youtube
Reza Rad
Trainer, Consultant, Mentor
Reza Rad is a Microsoft Regional Director, an Author, Trainer, Speaker and Consultant. He has a BSc in Computer engineering; he has more than 20 years’ experience in data analysis, BI, databases, programming, and development mostly on Microsoft technologies. He is a Microsoft Data Platform MVP for 12 continuous years (from 2011 till now) for his dedication in Microsoft BI. Reza is an active blogger and co-founder of RADACAD. Reza is also co-founder and co-organizer of Difinity conference in New Zealand, Power BI Summit, and Data Insight Summit.
Reza is author of more than 14 books on Microsoft Business Intelligence, most of these books are published under Power BI category. Among these are books such as Power BI DAX Simplified, Pro Power BI Architecture, Power BI from Rookie to Rock Star, Power Query books series, Row-Level Security in Power BI and etc.
He is an International Speaker in Microsoft Ignite, Microsoft Business Applications Summit, Data Insight Summit, PASS Summit, SQL Saturday and SQL user groups. And He is a Microsoft Certified Trainer.
Reza’s passion is to help you find the best data solution, he is Data enthusiast.
His articles on different aspects of technologies, especially on MS BI, can be found on his blog:

Leave a Reply