用conn.execute "if object_id('mydb..#tmp') is not null drop table #tmp" 为何删不掉临时表?
用“select * into #tmp from mytab”语句之前判断临时表是否存在,如果存在,则删除,用"if object_id('mydb..#tmp') is not null drop table #tmp",为什么删不掉,总提示#tmp已存在。 问题点数:20、回复次数:9Top
1 楼N_chow(Yukon)回复于 2002-05-27 10:55:05 得分 0
改一下:
IF OBJECT_ID(N'tempdb..#tmp') IS NOT NULL DROP TABLE #tmp
Top
2 楼jy0102(觉远)回复于 2002-05-27 11:36:10 得分 0
试了,也不行!Top
3 楼N_chow(Yukon)回复于 2002-05-27 11:44:49 得分 0
你的SQL Server版本??Top
4 楼ghxghx()回复于 2002-05-27 11:48:38 得分 0
是不是总提示#tmp不存在 ?
好像#tmp只在执行的时候才存在
我猜的
我一般用##tmp
Top
5 楼jy0102(觉远)回复于 2002-05-27 11:52:37 得分 0
提示已存在,是sqlerver7.0Top
6 楼N_chow(Yukon)回复于 2002-05-27 11:58:47 得分 0
你是不是有兩處以上的地方用到了SELECT * INTO #tmp From ...???
比如:
IF condition1
SELECT * INTO #tmp From ....
ELSE
SELECT * INTO #tmp From ...
???
是否是這樣??
Top
7 楼jy0102(觉远)回复于 2002-05-27 12:03:15 得分 0
conn.Execute "if object_id(N'ybccp..#tmp_Tday') is not null drop table #tmp_Tday"
conn.Execute "if object_id(N'ybccp..#tmp_Yday') is not null drop table #tmp_Yday"
conn.Execute "select * into #tmp_Tday from rcpkcb" conn.Execute "select * into #tmp_Yday from rcpkcb "Top
8 楼ghxghx()回复于 2002-05-27 12:08:13 得分 0
N_Chow(一劍飄香) 的答案
在我的sql server 2000 通过了Top
9 楼N_chow(Yukon)回复于 2002-05-27 12:11:12 得分 20
看一下:
http://www.csdn.net/Expert/TopicView1.asp?id=588007Top




