|
-
Sep 17th, 2011, 01:16 AM
#1
Thread Starter
Fanatic Member
[SQL2005] Variable Table Insert Select
Hi, is it possible to use columns using physical table and variable table under where statement?
Code:
insert into @tb1( local_off_totmins)
select sum(mint_usage)
from tblcalllogs a
where charge_type='local call' and net_type='offnet'
and a.phone_no = tblcalllogs.phone_no
im getting this error
Msg 4104, Level 16, State 1, Line 36
The multi-part identifier "tblcalllogs.phone_no" could not be bound.
Learn something new every .001 second. 
-
Sep 17th, 2011, 08:45 AM
#2
Re: [SQL2005] Variable Table Insert Select
Don't know if this is the error but You're comparing the field 'phone_no' against itself
'a.phone_no' and table 'tblcalllogs.phone_no' is the same table and the same field
Try next
Code:
Insert Into @tb1( local_off_totmins)
Select Sum(mint_usage)
From tblcalllogs
Where charge_type='local call' and net_type='offnet'
Last edited by jggtz; Sep 17th, 2011 at 11:34 AM.
JG
... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|