ÎÒÒª´´½¨Ò»¸öÁÙʱ±í±£´æÊý¾Ý ·½·¨Ò»£º declare @sql varchar(1000) set @sql = 'select identity(int,1,1) as tbId,* into #tb1 from table1 where 1=0' exec(@sql) select * from #tb1 drop table #tb1 ·½·¨¶þ£º select identity(int,1,1) as tbId,* into #tb2 from table1 where 1=0 select * from #tb2 drop table #tb2
·½·¨Ò»ÓÐÎÊÌ⣬ÇëÎÊÔõô½â¾ö£¬ÒòΪ±íÃûÊÇÐèÒªÓòÎÊý´«½øÀ´¡£SQL code: declare @sql varchar(1000) set @sql = 'select identity(int,1,1) as tbId,* into #tb1 from table1 where 1=0' exec(@sql+'; select * from #tb1; drop table #tb1')