我查询优化
if(condition 1)
begin
(
-----
-----
select into #temp1
----
drop #temp1
)
end
if(condition 2)
begin
(
-----
-----
select into #temp1
----
drop #temp1
)
end
现在这种格式的存储过程时,上面的存储过程是执行它为我的错误 说:
"There is already an object named '#temp1' in the database."
当我修改存储过程像,
if(condition 1)
begin
(
-----
-----
select into #temp1
----
drop #temp1
)
end
if(condition 2)
begin
(
-----
-----
select into #temp2
----
drop #temp2
)
end
它很好用,但我想优化这个,因为肌酸g太多的临时表。
有人能帮助我吗?
如果不存在,你可以不插入...',你正在使用什么sql引擎/服务器? – RobertPitt 2010-09-15 10:29:04
我认为条件1和条件2不相互排斥? '#temp1'和'#temp2'具有相同的结构吗? – 2010-09-15 10:57:07
你可以确认你是否使用SQLServer,如果是,哪个版本? – 2010-09-15 14:39:50