create procedure C
as
if(exists(select name from tempdb..sysobjects where name like'%A%' and type='U'))
begin
drop table #A
end
SELECT * INTO #A FROM tbTriopticsRowDataHistory
delete from #A
where operator like '%10CM%' and matchtype<>'T'
delete from #A
where operator not like '%10CM%' and matchtype<>'M'
消息 3701,级别 11,状态 5,过程 C,第 5 行 无法对 表'#A' 执行 删除,因为它不存在,或者您没有所需的权限。
(68677 行受影响)
(0 行受影响)
(0 行受影响)
(1 行受影响)
2 回答
翻阅古今
TA贡献1780条经验 获得超5个赞
你看一下你的if(exists(select name from tempdb..sysobjects where name like'%A%' and type='U')),这句是现在数据库中查询一下有没有对象名中带"A"的,有的话删掉,但是你删的时候删的是#A这个对象,你就这么确定一定存在这么一个对象?两个解决办法,确定就是要删除这个表的话,就改成这样if(exists(select name from tempdb..sysobjects where name ='#A' and type='U')),不确定的话就先查询出对象名,存放在变量中,再去删除。
紫衣仙女
TA贡献1839条经验 获得超15个赞
%A% 不代表#A,它可能是#ATR之内的,所以你的判断有问题,if(OBJECT_ID('tempdb..#t1') is not null)
drop table #t1 这样试试
- 2 回答
- 0 关注
- 479 浏览
添加回答
举报
0/150
提交
取消