为什么老提示“#a1”对象已经存在?
时间:2011-12-02
来源:互联网
select * into #a1 from table1
else
select * into #a1 from table1 where id>100
这明明不会同时执行的,为什么老提示“#a1”对象已经存在?
作者: glassy2000 发布时间: 2011-12-02
作者: xuam 发布时间: 2011-12-02
解决办法是,先创建临时表 #,再在if else 里用 insert 语句向其中插入值.
作者: qianjin036a 发布时间: 2011-12-02
Select * Into #a1 from table1 where 1<>1 if @type='all' insert #a1 select * from table1 else insert #a1 select * from table1 where id>100 --好像SQL的机制的原因吧.
作者: mustudent 发布时间: 2011-12-02
if object_id('tempdb..#a1') is not null drop table #a1 go if @type='all' select * into #a1 from table1 else select * into #a1 from table1 where id>100
作者: fredrickhu 发布时间: 2011-12-02
如果是在存储过程中的话,同一个存储过程不允许有两次 into #同名,尽管你放在不同的if else 块中.
解决办法是,先创建临时表 #,再在if else 里用 insert 语句向其中插入值.
1
作者: pengxuan 发布时间: 2011-12-02
看来比较麻烦
作者: glassy2000 发布时间: 2011-12-02
作者: jinfengyiye 发布时间: 2011-12-02
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28