创建临时表 试试insert into select * from exec(动态sql) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 insert into #tb exec(动态sql)不行,必须先创建表。 select * into #temp from exec(动态sql) 前提 #t已经创建,且结构一致insert into #t select * from exec(动态sql) 测试:select top 1 * into ##temp from sysobjectstruncate table ##tempinsert ##temp exec ('select * from sysobjects')select * from ##tempselect * from sysobjectsdrop table ##temp 先取出一部分数据,然后存储过程中的其它查询都要用到该表,这个本身就是一个很复杂的查询,所以想用临时表保存以提高速度。列都是动态生成的,要是用create table 的话,怎么用? 先取出一部分数据,然后存储过程中的其它查询都要用到该表,这个本身就是一个很复杂的查询,所以想用临时表保存以提高速度。列都是动态生成的,要是用create table 的话,怎么用?if object_id('tempdb..##temp') is not null drop table ##tempexec ('create table ##temp (你的动态描述)')insert ##temp exe ('你的动态结果集') 可以呀,不過你得創建有兩個##的全局表。如果你用一個#,你exec(@sql)後就沒有了。 关于视图的另一问题,高手再请进! 求一条超难的sql语句?? 求一SQL语句,分组后Count 如果把字符中的数字找出来 求教~访问其他工作组中的SQLSERVER2000 存储过程小小问题 我的sql server2000老是安装不成功,请指教! 一个菜鸟的问题 奇怪的排序问题。 access升级mssql后表单提交出错,求助(附代码) 如何定时地将一台sql server的数据库 备份到另一台sql server上去呀 各位帮忙改写一下存储过程!
insert into #t select * from exec(动态sql)
select top 1 * into ##temp from sysobjects
truncate table ##temp
insert ##temp exec ('select * from sysobjects')
select * from ##temp
select * from sysobjects
drop table ##temp
所以想用临时表保存以提高速度。列都是动态生成的,要是用create table 的话,怎么用?
所以想用临时表保存以提高速度。列都是动态生成的,要是用create table 的话,怎么用?if object_id('tempdb..##temp') is not null drop table ##temp
exec ('create table ##temp (你的动态描述)')
insert ##temp exe ('你的动态结果集')
如果你用一個#,你exec(@sql)後就沒有了。