if 语句问题!!(老是提示#a已经存在)

azhhuoiu 2007-07-24 05:52:07
declare @k int
if object_id('tempdb..#aa') is null
begin
set @k=1
end
if object_id('tempdb..#aaa') is null
begin
set @k=1
end
if object_id('tempdb..#aaaa') is null
begin
set @k=1
end
else
begin
select * into #a from (select * from #aaaa)bb
end
else
begin
select * into #a from (select * from #aaa) bb
end
else
begin
select * into #a from (select * from #aa) bb
end
...全文
175 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
谁是谁的谁 2007-07-24
  • 打赏
  • 举报
回复
路过,学习ing...
Slayer_Boxer 2007-07-24
  • 打赏
  • 举报
回复
看不懂..
  • 打赏
  • 举报
回复
if object_id('tempdb..#aa') is not null
这句的效率是不是有点低???
  • 打赏
  • 举报
回复
执行drop把临时表删掉。
临时表用完后要删掉的
SoftwKLC 2007-07-24
  • 打赏
  • 举报
回复
--建议楼主用以下的方式写可能会比较好一点
if object_id('tempdb..#aa') is not null
drop table tempdb..#aa
go
if object_id('tempdb..#aaaa') is not null
drop table tempdb..#aaaa
go
....
comszsoft 2007-07-24
  • 打赏
  • 举报
回复
用后 drop 掉。

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧