...bringing you notes from the field...

Tag Cloud


SQL Server: Why do I get "multi-part identifier could not be bound" ?

 

Let's say you've developed a stored procedure that assigns a count value to a variable which looks like this:

SELECT @HasDefaultShipTo = count(*)
  FROM StakeHolderLoc_Assoc 
    WHERE assoc.StakeHldrID = @StkhldrID

When you execute to compile you will see the error:

Msg 4104, Level 16, State 1, Procedure MetroDevETL_1, Line 80
The multi-part identifier "assoc.StakeHldrID" could not be bound.

The reason this error appears is because you have forgotten to associate/bind the table to "assoc". The corrected SQL will look like this:

SELECT @HasDefaultShipTo = count(*)
  FROM StakeHolderLoc_Assoc assoc
    WHERE assoc.StakeHldrID = @StkhldrID

 


  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

# re: SQL Server: Why do I get "multi-part identifier could not be bound" ?

This helped, thanks.

I was trying to declare two different variables, and ended up repeating the FROM and WHERE statement, even though it was coming from the same table. 1/12/2011 8:39 AM | Aligolightly