CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  MS-SQL Server >  基础类

用conn.execute "if object_id('mydb..#tmp') is not null drop table #tmp" 为何删不掉临时表?

楼主jy0102(觉远)2002-05-27 10:47:23 在 MS-SQL Server / 基础类 提问

用“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

相关问题

  • this==NULL???
  • to :nononono(null,null)
  • nononono(null,null)!!!!
  • javax.ejb.NoSuchObjectLocalException: null; CausedByException is:null
  • a==null 和 a is null
  • Test(NULL)
  • Update NULL
  • to: nononono(null,null),再来!
  • nononono(null,null)在么?
  • while(GetMessage(&msg,NULL,NULL,NULL))的处理

关键词

  • null
  • tmp
  • tday
  • yday
  • conn
  • execute
  • 存在
  • null drop table
  • select
  • if object

得分解答快速导航

  • 帖主:jy0102
  • N_chow

相关链接

  • SQL Server类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo