22,181
社区成员




if object_id( 'tempdb..#t ') is not null
drop table #t
GO
CREATE TABLE #T (ID INT ,.....)
if .....
INSERT #t SELECT * from tab where....
else if ....
INSERT #t SELECT * from tab where...
else if ...
INSERT #t SELECT * from tab where...
select .... from #t where ...
drop table #t
if object_id('tempdb..#t') is not null drop #t
if .....
select * into #t from tab where....
else if ....
select * into #t from tab where...
else if ...
select * into #t from tab where...
select .... from #t where ...
drop table #t
更改为
select * into #1 from tab where 1 =2
if ...
insert #1 select * from tab where
else if ...
insert #1 select * from tab where
drop table #1
IF OBJECT_ID('TEMPDB..#t')IS NOT NULL DROP TABLE #T