日期:2014-05-18  浏览次数:20521 次

这个储存过程怎么写?
我搜索从两个表里面搜索出两个值 想插入到一张零时表里面 怎么弄呢?


ALTER proc [dbo].[pro_LeaveMoney]
as

select sum(InCome) as InCome from InCome
select SUM(cost) as Cost from Spend


sum(InCome) 总收入
SUM(cost) 总花费

这两个字段

------解决方案--------------------
create proc [dbo].[pro_LeaveMoney]
as
begin
insert into tmp(col) select sum(InCome) as InCome from InCome
insert into tmp(col) select SUM(cost) as Cost from Spend
end
go

--or
create proc [dbo].[pro_LeaveMoney]
as
begin
insert into tmp(col) 
select sum(InCome) as InCome from InCome
union all 
select SUM(cost) as Cost from Spend
end
go