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 |
|
Randjana
Starting Member
9 Posts |
Posted - 2008-01-22 : 13:00:00
|
| Dear all,I'm trying to run a query with no luck, I'm getting "The multi-part identifier "table2.qty" could not be bound."Here is my query:select cust_nam , dat ,item_no , desc_lin_1,table2.qty prc, cost, ret_reas_cod,(table2.qty*cost) from table1,table2 where hdr_ticket_no = ticket_no and dat >= '20080101' and cat = 'test' and hdr_ticket_no in( select ticket_no from table1 where dat >= '20080101')order by datI have 2 databases on my sql server. If i choose the other one then this query runs but, if i choose the one that contains the tables I just get that error.Strange part is that it runs under the database that doesn't even contains the table.If i remove qty from the list then it runs ok. both tables have a qty column. What I'm doing wrong? Any help would be appreciated. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-22 : 13:04:55
|
| can you try using ANSI syntax:-select cust_nam , dat ,item_no , desc_lin_1,t2.qty prc, cost, ret_reas_cod,t2.qty*cost as col from table1 t1Inner join table2 t2ON t1.hdr_ticket_no = t2.ticket_no WHere dat >= '20080101' and cat = 'test' and hdr_ticket_no in( select ticket_no from table1 where dat >= '20080101')order by dat |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-01-22 : 13:07:12
|
| another possibility:sounds like table2 is a VIEW rather than a table. If so, check out the view definition. Perhaps an underlying table had a structure change?Be One with the OptimizerTG |
 |
|
|
Randjana
Starting Member
9 Posts |
Posted - 2008-01-22 : 13:14:17
|
Thank you Visakh16! It just worked and i was fighting with this thing more than 2 days!! Thanks a lot! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-22 : 13:17:44
|
| You are welcome. Always its better to code in ANSI syntax. |
 |
|
|
|
|
|
|
|