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.
| 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 400The multi-part identifier "pos_policy_raterinfo.pos_id" could not be bound.Msg 4104, Level 16, State 1, Procedure pos_populate, Line 400The 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_driverset pos_driver.riding_experience = ( pos_driver.riding_experience / 12 )where pos_driver.pos_id = @pos_idand pos_driver.pos_id = pos_policy_raterinfo.pos_idand pos_policy_raterinfo.rater_id = 11if (@@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_driverset 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 |
 |
|
|
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. |
 |
|
|
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 Driverset riding_experience = (Driver.riding_experience / 12)from pos_driver as Driverinner join pos_policy_raterinfo AS Policy on Driver.pos_id = Policy.pos_idwhere Driver.pos_id = @pos_id and Policy.rater_id = 11 |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-07-27 : 17:53:34
|
| update posdset posd.riding_experience = ( posd.riding_experience / 12 )from pos_driver posdinner join pos_policy_raterinfo posppron posd.pos_id = posppr.posi_iddwhere posd.pos_id = @pos_id and posppr.rater_id = 11 |
 |
|
|
chedderslam
Posting Yak Master
223 Posts |
Posted - 2009-07-28 : 09:24:02
|
| That worked. Thank you. Why are the aliases required? |
 |
|
|
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. |
 |
|
|
|
|
|
|
|