我正在使用sybase ASE 15.寻找这样的东西
Select * into #tmp exec my_stp;
my_stp返回每行中有两列的10个数据行。
发布于 2018-06-12 09:15:15
这是可行的,涉及一个Sybase“ 代理表 ”,该表代表另一个本地或远程对象(表,过程,视图)。下面的12.5版本,更新的版本希望有更好的方式来做到这一点。
假设你有一个存储过程定义如下:
create procedure mydb.mylogin.sp_extractSomething (
@timestamp datetime) as
select column_a, column_b
from sometable
where timestamp = @timestamp
首先切换到tempdb:
use tempdb
然后创建一个代理表,其中的列与结果集匹配:
create existing table myproxy_extractSomething (
column_a int not null, -- make sure that the types match up exactly!
column_b varchar(20) not null,
_timestamp datetime null,
primary key (column_a)) external procedure at "loopback.mydb.mylogin.sp_extractSomething"
注意事项:
然后你可以从你自己的数据库中选择这样的表格:
declare @myTimestamp datetime
set @myTimestamp = getdate()
select *
from tempdb..myproxy_extractSomething
where _timestamp = @myTimestamp
这足够简单。然后插入到临时表中,首先创建它:
create table #myTempExtract (
column_a int not null, -- again, make sure that the types match up exactly
column_b varchar(20) not null,
primary key (column_a)
)
并结合:
insert into #myTempExtract (column_a, column_b)
select column_a, column_b
from tempdb..myproxy_extractSomething
where _timestamp = @myTimestamp
发布于 2018-06-12 10:38:23
不确定Sybase,但在SQLServer中,以下内容应该可以工作:
插入#tmp(col1,col2,col3.)_STP
https://stackoverflow.com/questions/-100000251
复制相似问题