I just upgraded to SQL Server 2005 Standard Edition for my home Dev work.
When I SELECT a column from a table and JOIN with that same column I get a weird error message. I've been Googling it for about 20 minutes and found people with the same problem, but no answer was given.
Oddly enough, I searched this site and it seems I'm the first to come across it here.
Here is the error msg:
I've been able to get around it on a few queries but this one won't display any data with the previous workarounds:
I had to change the table and column names as I'm a consultant and my company doesn't take kindly to posting their "proprietary" quieries on the web, but I was careful in my changes (I think) so it's exactly the same structure, just different names.
Why does a query like this error out in SQL 2005? I've done one right before it exactly the same
- with 2 tables in the FROM and a bunch of JOINS with a WHERE defining the rough conditions that would require too many more JOINs on the same table -
and it worked fine. The only difference was I was SELECTing the sa.svr_area_id and using it in the JOIN this time, and if I comment that first JOIN out it will run, just not correctly. I don't think doing that ever bombed out on me before ????
Any ideas?
When I SELECT a column from a table and JOIN with that same column I get a weird error message. I've been Googling it for about 20 minutes and found people with the same problem, but no answer was given.
Oddly enough, I searched this site and it seems I'm the first to come across it here.
Here is the error msg:
Code:
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "sa.svr_area_id" could not be bound.
I've been able to get around it on a few queries but this one won't display any data with the previous workarounds:
Code:
INSERT INTO base.area_attributes
(
app_attribute_id,
svr_area_id,
user_id_create,
create_date,
user_id_update,
update_date
)
SELECT DISTINCT
aa.app_attribute_id,
sa.svr_area_id,
1,
getDate(),
1,
getDate()
FROM base.svr_areas sa,
base.app_attributes aa
JOIN base.base_type_svr_areas btsa
ON sa.svr_area_id = btsa.svr_area_id
JOIN base.base_types bt
ON btsa.base_type_id = bt.type_id
JOIN mode.defaults def
ON bt.default_id = def.default_id
JOIN base.app_attribute_types aat
ON aat.[name] = 'Data Type'
WHERE (def.business_name = 'Some Data'
AND (aa.[name] = 'Some different data'
OR aa.[name] = 'Some more different data'))
OR (def.business_name = 'More Data'
AND (aa.[name] = 'Some more different data'))
OR (def.business_name = 'Some Data #2'
AND (aa.[name] = 'Some more different data'))
I had to change the table and column names as I'm a consultant and my company doesn't take kindly to posting their "proprietary" quieries on the web, but I was careful in my changes (I think) so it's exactly the same structure, just different names.
Why does a query like this error out in SQL 2005? I've done one right before it exactly the same
- with 2 tables in the FROM and a bunch of JOINS with a WHERE defining the rough conditions that would require too many more JOINs on the same table -
and it worked fine. The only difference was I was SELECTing the sa.svr_area_id and using it in the JOIN this time, and if I comment that first JOIN out it will run, just not correctly. I don't think doing that ever bombed out on me before ????
Any ideas?