2 回答

TA貢獻(xiàn)1780條經(jīng)驗(yàn) 獲得超5個(gè)贊
你看一下你的if(exists(select name from tempdb..sysobjects where name like'%A%' and type='U')),這句是現(xiàn)在數(shù)據(jù)庫(kù)中查詢一下有沒(méi)有對(duì)象名中帶"A"的,有的話刪掉,但是你刪的時(shí)候刪的是#A這個(gè)對(duì)象,你就這么確定一定存在這么一個(gè)對(duì)象??jī)蓚€(gè)解決辦法,確定就是要?jiǎng)h除這個(gè)表的話,就改成這樣if(exists(select name from tempdb..sysobjects where name?='#A' and type='U')),不確定的話就先查詢出對(duì)象名,存放在變量中,再去刪除。

TA貢獻(xiàn)1839條經(jīng)驗(yàn) 獲得超15個(gè)贊
%A% 不代表#A,它可能是#ATR之內(nèi)的,所以你的判斷有問(wèn)題,if(OBJECT_ID('tempdb..#t1') is not null)
?drop table #t1 這樣試試
- 2 回答
- 0 關(guān)注
- 509 瀏覽
添加回答
舉報(bào)