经常遇到将exec(@sql)的执行结果要插入到临时表中,但是插入都会失败,

其实SQL是可以将exec(@sql)的执行结果插入到临时表中的

请参考:
-- 定义表变量

create table #temp
(
 i int
)

declare @sql varchar(100)

set @sql = 'select 1'

insert into #temp(i) exec(@sql)

select * from #temp

drop table #temp

相关文章:

  • 2021-08-24
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-06
  • 2021-06-15
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-24
相关资源
相似解决方案