怎样在存储过程中建立临时表,提出数据后再删除它

fiter 2004-03-26 09:30:55
AS
BEGIN
select 书商=a.seller_desc, 经费=sum(b.fund_amount) into #temptalbe
from mark.booksellers as a inner join mark.trade_payment as b
on a.seller_id=b.seller_id
where (b.library_id=@lib_code)
and(@begin_time<=b.trade_date)
and(@end_time>=b.trade_date)
group by a.seller_id
END

因为加了#temptable提示
sybase
the 'CREATE TABLE'command is not allowed within a multi-statement
transaction in the 'tempdb' database

请同志们赐教,存储过程怎么建临时表,然后在从临时表中读取数据,然后在删除临时表。不知道临时表开销大不大,如果图书馆项目有几万记录用临时表会慢吗?
...全文
144 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
lilei_jn 2004-08-20
  • 打赏
  • 举报
回复
不错可以了
VCILOVE 2004-04-26
  • 打赏
  • 举报
回复
就是要设置sp_dboption 'select into/bulkcopy/pllsort',true
就可以了
fiter 2004-04-25
  • 打赏
  • 举报
回复
自己顶
lilei_jn 2004-04-09
  • 打赏
  • 举报
回复
关注
damangren 2004-03-30
  • 打赏
  • 举报
回复
使用wanyong1980() 的方法,然后重新启动数据库服务。
fiter 2004-03-29
  • 打赏
  • 举报
回复
不好使亚
hongst 2004-03-29
  • 打赏
  • 举报
回复
如果是ASE的话,你可以用
insert into #table1
select * from table2
试试
tolison 2004-03-28
  • 打赏
  • 举报
回复
你得过程大概是在事务中执行的,去掉事务再试试。
sp_dboption 'select into/bulkcopy/pllsort',true
go
sp_dboption 'ddl in tran',true
go
wanyong1980 2004-03-26
  • 打赏
  • 举报
回复
在存储过程里直接建
create talbe #temptable
(.....)
要看tempdb大小了,还有#temptable就是一个表,开销和普通表一样
存储过程之行之后直接就删除了。

2,596

社区成员

发帖
与我相关
我的任务
社区描述
Sybase相关技术讨论区
社区管理员
  • Sybase社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧