Results 1 to 2 of 2

Thread: [SQL2005] Variable Table Insert Select

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    617

    [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.

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    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
  •  



Click Here to Expand Forum to Full Width