Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 The multi-part identifier could not be bound.

Author  Topic 

chedderslam
Posting Yak Master

223 Posts

Posted - 2009-07-27 : 16:46:04
I know this is a common issue from all the info on Google, but none of the approaches I have seen mentioned seem to fit. I am getting the following error when I try to deploy this stored procedure:

Msg 4104, Level 16, State 1, Procedure pos_populate, Line 400
The multi-part identifier "pos_policy_raterinfo.pos_id" could not be bound.
Msg 4104, Level 16, State 1, Procedure pos_populate, Line 400
The multi-part identifier "pos_policy_raterinfo.rater_id" could not be bound.

This is the portion it is talking about. The table and columns exist, and I can run a straight select from the table without issue. Please help.

/* Conversion of riding_experience from months to years for True Premium */
update pos_driver
set pos_driver.riding_experience = ( pos_driver.riding_experience / 12 )
where pos_driver.pos_id = @pos_id
and pos_driver.pos_id = pos_policy_raterinfo.pos_id
and pos_policy_raterinfo.rater_id = 11
if (@@error <> 0) goto exception

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-07-27 : 16:57:58
How did this table get into the mix?:
update 
pos_driver
set
pos_driver.riding_experience = ( pos_driver.riding_experience / 12 )
where
pos_driver.pos_id = @pos_id
and pos_driver.pos_id = pos_policy_raterinfo.pos_id
and pos_policy_raterinfo.rater_id = 11
Go to Top of Page

chedderslam
Posting Yak Master

223 Posts

Posted - 2009-07-27 : 17:37:47
It is used to limit the records updated to only those from that rater. The rater with id of 11 is passing in experience as months instead of years like everyone else, thus the need for this update.
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-07-27 : 17:49:33
Then you will need some way to associate the two tables. One way would be with a join (untested):
update 
Driver
set
riding_experience = (Driver.riding_experience / 12)
from
pos_driver as Driver
inner join
pos_policy_raterinfo AS Policy
on Driver.pos_id = Policy.pos_id
where
Driver.pos_id = @pos_id
and Policy.rater_id = 11
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-07-27 : 17:53:34
update posd
set posd.riding_experience = ( posd.riding_experience / 12 )
from pos_driver posd
inner join pos_policy_raterinfo posppr
on
posd.pos_id = posppr.posi_idd
where posd.pos_id = @pos_id

and posppr.rater_id = 11
Go to Top of Page

chedderslam
Posting Yak Master

223 Posts

Posted - 2009-07-28 : 09:24:02
That worked. Thank you. Why are the aliases required?
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-07-28 : 12:10:24
They aren't required. Some people find it easier to read and, potentially, less typing. But, it doesn't matter.
Go to Top of Page
   

- Advertisement -