Advertisement

05.27.2004 at 06:24AM PDT, ID: 21004314
[x]
Attachment Details

There is already an object named '#baseline1' in the database.

Asked by sahnias in MS SQL Server

Tags: already, object, named, database

I am getting an error when i try to parse the query:

Server: Msg 2714, Level 16, State 1, Procedure ap_rpt_chunit, Line 32
There is already an object named '#baseline1' in the database.
Server: Msg 2714, Level 16, State 1, Procedure ap_rpt_chunit, Line 50
There is already an object named '#baseline1' in the database.
Server: Msg 2714, Level 16, State 1, Procedure ap_rpt_chunit, Line 64
There is already an object named '#baseline1' in the database.

And these point to where i have written :

into #baseline1

Below is the SP,

Create procedure dbo.ap_rpt_chunit
@gdfdate datetime,
@gdtdate datetime,
@gdjets bit,
@gdclient varchar(6)
As
begin

If @gdjets = 1
begin
      If @gdclient = ''
      begin
            Select b.billing_ref, b.billable_id, b.flight_id, b.depart, b.dest,
                  b.flightdate,b.cdn_dist,b.billdist,b.direction,b.route,s.client_id,
                  s.ac_Type, s.ac_ident,s.enroute, s.terminal, s.chargetype_code,
                  s.mtow,m.invoice_no,i.invoice_line_id, i.credit_line_id
            into #baseline1
            from billing b ,b_Status_hist s, inv_det i, inv_summ m
            where b.billable_id = s.billable_id
                  and s.billable_id = i.billable_id
                  and i.invoice_id = m.invoice_id
                  and b.flightdate > = @gdfdate and b.flightdate <= @gdtdate
                  and s.mtow > 8.0 and ac_type in (Select ac_Type from ac_Type where powplant = 'J')
      end
      Else
      begin
            Select b.billing_ref, b.billable_id, b.flight_id, b.depart, b.dest,
                  b.flightdate,b.cdn_dist,b.billdist,b.direction,b.route,s.client_id,
                  s.ac_Type, s.ac_ident,s.enroute, s.terminal, s.chargetype_code,
                  s.mtow,m.invoice_no,i.invoice_line_id, i.credit_line_id
            into #baseline1
            from billing b ,b_Status_hist s, inv_det i, inv_summ m
            where b.billable_id = s.billable_id
                  and s.billable_id = i.billable_id
                  and i.invoice_id = m.invoice_id
                  and b.flightdate > = @gdfdate and b.flightdate <= @gdtdate
                  and m.client_id = @gdclient
                  and s.mtow > 8.0 and ac_type in (Select ac_Type from ac_Type where powplant = 'J')
      end
End
Else
begin
      If @gdclient = ''
      begin
            Select b.billing_ref, b.billable_id, b.flight_id, b.depart, b.dest,
                  b.flightdate,b.cdn_dist,b.billdist,b.direction,b.route,s.client_id,
                  s.ac_Type, s.ac_ident,s.enroute, s.terminal, s.chargetype_code,
                  s.mtow,m.invoice_no,i.invoice_line_id, i.credit_line_id
            into #baseline1
            from billing b ,b_Status_hist s, inv_det i, inv_summ m
            where b.billable_id = s.billable_id
                  and s.billable_id = i.billable_id
                  and i.invoice_id = m.invoice_id
                  and b.flightdate > = @gdfdate and b.flightdate <= @gdtdate
                  and s.chargetype_code = 'M'
      end      
      Else
      begin
            Select b.billing_ref, b.billable_id, b.flight_id, b.depart, b.dest,
                  b.flightdate,b.cdn_dist,b.billdist,b.direction,b.route,s.client_id,
                  s.ac_Type, s.ac_ident,s.enroute, s.terminal, s.chargetype_code,
                  s.mtow,m.invoice_no,i.invoice_line_id, i.credit_line_id
            into #baseline1
            from billing b ,b_Status_hist s, inv_det i, inv_summ m
            where b.billable_id = s.billable_id
                  and s.billable_id = i.billable_id
                  and i.invoice_id = m.invoice_id
                  and b.flightdate >= @gdfdate and b.flightdate <= @gdtdate
                  and s.chargetype_code = 'M' and s.client_id = @gdclient
      end
end

select c.billable_id,s.*
into #baseline2
from cred_Det c, cred_summ s
where c.credit_id = s.credit_id

Select b1.billing_ref, b1.billable_id, b1.flight_id, b1.depart, b1.dest,
      b1.flightdate,b1.cdn_dist,b1.billdist,b1.direction,b1.route,b1.client_id,
      b1.ac_Type, b1.ac_ident,b1.enroute, b1.terminal, b1.chargetype_code,
      b1.mtow,b1.invoice_no,b1.invoice_line_id,b1.credit_line_id
from #baseline1 b1
where b1.billable_id not in (Select billable_id from #baseline2)

end

can anyone tell me how can i get rid of this error. Start Free Trial
[+][-]05.27.2004 at 06:30AM PDT, ID: 11171282

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2004 at 06:40AM PDT, ID: 11171407

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Tags: already, object, named, database
Sign Up Now!
Solution Provided By: ill
Participating Experts: 3
Solution Grade: A
 
 
[+][-]05.27.2004 at 06:42AM PDT, ID: 11171423

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.27.2004 at 06:50AM PDT, ID: 11171512

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2004 at 07:41AM PDT, ID: 11172129

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2004 at 07:43AM PDT, ID: 11172160

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2004 at 08:39AM PDT, ID: 11172788

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32