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.invo
ice_line_i
d, 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.invo
ice_line_i
d, 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.invo
ice_line_i
d, 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.invo
ice_line_i
d, 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.billdis
t,b1.direc
tion,b1.ro
ute,b1.cli
ent_id,
b1.ac_Type, b1.ac_ident,b1.enroute, b1.terminal, b1.chargetype_code,
b1.mtow,b1.invoice_no,b1.i
nvoice_lin
e_id,b1.cr
edit_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