日期:2014-05-18 浏览次数:20617 次
declare @sql varchar(200) set @sql = 'select 10 as id into #t ' exec(@sql) select * from #t drop table #t
select * from (select 10 as id)t into #t
------解决方案--------------------
不能这样写的.
declare @sql varchar(200) create table #t(id int) set @sql = 'select 10 as id' insert into #t exec(@sql) select * from #t /* id ----------- 10 (1 行受影响) */ drop table #t
------解决方案--------------------
declare @sql varchar(200) create table #t(id int) set @sql = 'select 10 as id' insert into #t exec(@sql) select * from #t
------解决方案--------------------
1楼不是写给你select ... into ...的用法了么?
--写错了,改下,汗 select * into #t from (select 10 as id)t
------解决方案--------------------
--我晕,静态的你会了,改动态的不会? declare @sql varchar(200) if object_id('#t') is not null drop table #t set @sql = 'select * into #t from (select 10 as id)t' exec(@sql) select * from #t