if (1=2) begin
IF OBJECT_ID('TEMPDB..#temp') is NOT null drop table #temp
select 1 as num into #temp
END
else BEGIN
IF OBJECT_ID('TEMPDB..#temp') is NOT null drop table #temp
select 2 as num into #temp
END
------
declare @SQL_ NVARCHAR(MAX)
IF OBJECT_ID('TEMPDB..#temp') is NOT null drop table #temp
if (1=2) begin
SET @SQL_='select 1 as num into #tempt'
END
else BEGIN
SET @SQL_='select 2 as num into #tempt'
END
EXEC (@SQL_)
![1663747330213015.png image.png](/upload/wenda/20220921/1663747330213015.png)
--------------
![1663748537487752.png image.png](/upload/wenda/20220921/1663748537487752.png)