I am trying to drop a temporary table but I get this error message. This same script used to run in SQL Server 2000 and now we upgraded to 2005 and its not working. I am not sure if it is a permission issue or not.
ERROR MESSAGE
Cannot drop the table '#outline_codes', because it does not exist or you do not have permission.
SCRIPT:
--drop outline codes table before running
drop table #outline_codes
(
select *
into #outline_codes
from MSP_outline_codes
where proj_id in
(select PROJ_ID from MSP_PROJECTS where PROJ_TYPE = 2)
and code_uid > 0
)
go
--drop #funded_portfolio_projects table
drop table #funded_portfolio_projects
--table to identify funded portfolio projects
(
select mcf.proj_id
into #funded_portfolio_projects
from #outline_codes oc, msp_code_fields mcf
where oc.code_uid = mcf.code_uid
and (((oc_field_id = 188744593 and oc_name like 'yes')
or (oc_field_id = 188744592 and oc_name like 'application portfolio')))
or mcf.proj_id = 283
group by mcf.proj_id
having count(oc_field_id) > 1
)
go
--drop the milestone table
drop table #dashboard_milestones
--table to dashboard milestone information
(
select p.proj_id,
p.proj_name,
t.task_uid,
t.task_name,
oc_name,
t.TASK_START_DATE,
t.TASK_FINISH_DATE,
t.TASK_ACT_START,
t.TASK_ACT_FINISH,
t.task_base_start,
t.task_base_finish,
t.[TASK_WORK]/60000 as work,
t.task_act_work/60000 as act_work,
t.task_base_work/60000 as base_work,
t.TASK_PHY_PCT_COMP,
t.Task_Base_cost*.01 as base_cost,
t.Task_cost *.01 as cost,
t.Task_act_cost*.01 as act_cost,
t.Task_pct_comp as PCT_COMP,
t.Task_pct_work_comp as PCT_work_COMP,
t.Task_BCWS*.01 as BCWS
into #dashboard_milestones
from #outline_codes toc, msp_code_fields mcf, MSP_projects p, msp_tasks t, #funded_portfolio_projects fp
where toc.code_uid = mcf.code_uid
and p.proj_id = mcf.proj_id
and p.proj_id = t.proj_id
and p.proj_id = fp.proj_id
and mcf.code_ref_uid = t.task_uid
and (oc_name like 'accepted'
or oc_name like 'tentative')
and p.proj_version = 'published'
)
go
--add highest summary level tasks from each project to #dashboard_milestones table
insert into #dashboard_milestones
(
proj_id,
proj_name,
t.task_uid,
task_name,
oc_name,
TASK_START_DATE,
TASK_FINISH_DATE,
TASK_ACT_START,
TASK_ACT_FINISH,
TASK_BASE_START,
TASK_BASE_FINISH,
work,
act_work,
BASE_WORK,
TASK_PHY_PCT_COMP,
base_cost,
cost,
act_cost,
PCT_COMP,
PCT_work_COMP,
BCWS
)
select p.proj_id,
p.proj_name,
t.task_uid,
t.task_name,
null as oc_name,
t.TASK_START_DATE,
t.TASK_FINISH_DATE,
t.TASK_ACT_START,
t.TASK_ACT_FINISH,
T.TASK_BASE_START,
T.TASK_BASE_FINISH,
t.[TASK_WORK]/60000 as work,
t.task_act_work/60000 as act_work,
T.TASK_BASE_WORK/60000 AS BASE_WORK,
t.TASK_PHY_PCT_COMP,
t.Task_Base_cost *.01 as base_cost,
t.Task_cost *.01 as cost,
t.Task_act_cost *.01 as act_cost,
t.Task_pct_comp as PCT_COMP,
t.Task_pct_work_comp as PCT_work_COMP,
t.Task_BCWS*.01 as BCWS
from MSP_projects p, msp_tasks t, #funded_portfolio_projects fp
where p.proj_id = t.proj_id
and p.proj_id = fp.proj_id
and t.task_uid = 0
and p.proj_version = 'published'
ERROR MESSAGE
Cannot drop the table '#outline_codes', because it does not exist or you do not have permission.
SCRIPT:
--drop outline codes table before running
drop table #outline_codes
(
select *
into #outline_codes
from MSP_outline_codes
where proj_id in
(select PROJ_ID from MSP_PROJECTS where PROJ_TYPE = 2)
and code_uid > 0
)
go
--drop #funded_portfolio_projects table
drop table #funded_portfolio_projects
--table to identify funded portfolio projects
(
select mcf.proj_id
into #funded_portfolio_projects
from #outline_codes oc, msp_code_fields mcf
where oc.code_uid = mcf.code_uid
and (((oc_field_id = 188744593 and oc_name like 'yes')
or (oc_field_id = 188744592 and oc_name like 'application portfolio')))
or mcf.proj_id = 283
group by mcf.proj_id
having count(oc_field_id) > 1
)
go
--drop the milestone table
drop table #dashboard_milestones
--table to dashboard milestone information
(
select p.proj_id,
p.proj_name,
t.task_uid,
t.task_name,
oc_name,
t.TASK_START_DATE,
t.TASK_FINISH_DATE,
t.TASK_ACT_START,
t.TASK_ACT_FINISH,
t.task_base_start,
t.task_base_finish,
t.[TASK_WORK]/60000 as work,
t.task_act_work/60000 as act_work,
t.task_base_work/60000 as base_work,
t.TASK_PHY_PCT_COMP,
t.Task_Base_cost*.01 as base_cost,
t.Task_cost *.01 as cost,
t.Task_act_cost*.01 as act_cost,
t.Task_pct_comp as PCT_COMP,
t.Task_pct_work_comp as PCT_work_COMP,
t.Task_BCWS*.01 as BCWS
into #dashboard_milestones
from #outline_codes toc, msp_code_fields mcf, MSP_projects p, msp_tasks t, #funded_portfolio_projects fp
where toc.code_uid = mcf.code_uid
and p.proj_id = mcf.proj_id
and p.proj_id = t.proj_id
and p.proj_id = fp.proj_id
and mcf.code_ref_uid = t.task_uid
and (oc_name like 'accepted'
or oc_name like 'tentative')
and p.proj_version = 'published'
)
go
--add highest summary level tasks from each project to #dashboard_milestones table
insert into #dashboard_milestones
(
proj_id,
proj_name,
t.task_uid,
task_name,
oc_name,
TASK_START_DATE,
TASK_FINISH_DATE,
TASK_ACT_START,
TASK_ACT_FINISH,
TASK_BASE_START,
TASK_BASE_FINISH,
work,
act_work,
BASE_WORK,
TASK_PHY_PCT_COMP,
base_cost,
cost,
act_cost,
PCT_COMP,
PCT_work_COMP,
BCWS
)
select p.proj_id,
p.proj_name,
t.task_uid,
t.task_name,
null as oc_name,
t.TASK_START_DATE,
t.TASK_FINISH_DATE,
t.TASK_ACT_START,
t.TASK_ACT_FINISH,
T.TASK_BASE_START,
T.TASK_BASE_FINISH,
t.[TASK_WORK]/60000 as work,
t.task_act_work/60000 as act_work,
T.TASK_BASE_WORK/60000 AS BASE_WORK,
t.TASK_PHY_PCT_COMP,
t.Task_Base_cost *.01 as base_cost,
t.Task_cost *.01 as cost,
t.Task_act_cost *.01 as act_cost,
t.Task_pct_comp as PCT_COMP,
t.Task_pct_work_comp as PCT_work_COMP,
t.Task_BCWS*.01 as BCWS
from MSP_projects p, msp_tasks t, #funded_portfolio_projects fp
where p.proj_id = t.proj_id
and p.proj_id = fp.proj_id
and t.task_uid = 0
and p.proj_version = 'published'