首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

(!)存储过程的有关问题

2012-03-07 
(!!!急)存储过程的问题CREATEPROCEDUREselect_aForumTitle_1(@DisAreaIdint)asselectcount(Content)ascoun

(!!!急)存储过程的问题
CREATE   PROCEDURE     select_aForumTitle_1
(
        @DisAreaId     int
)
as
select   count(Content)   as   count1
from
            aContent
join  
            aForum
on
          aContent.ForumId=aForum.Id
  where
          aForum.DisAreaId=@DisAreaId
group   by
            ForumId
GO


CREATE   PROCEDURE   select_aForumTitle
(
          @DisAreaId   int
)
as

select
        b.Id   ,a.Title,b.SendName   as   Name2,b.AddTime,c.Name
from
          aDisArea   as   a
join
          aForum   as   b
on
          b.DisAreaId=a.Id
join
          aMember   as   c
on
        b.SendId=c.Id
where
        b.DisAreaId=@DisAreaId
order   by
          a.AddTime
GO
请问怎么把这两个存储过程合并成一个存储过程呢??)

[解决办法]
CREATE PROCEDURE select_aForumTitle
@DisAreaId int
as
begin
declare @tcount int
select
@tcount=isnull(count(Content),0)
from
aContent
join
aForum
on
aContent.ForumId=aForum.Id
where
aForum.DisAreaId=@DisAreaId
group by
ForumId

select
@tcount as count1,b.Id ,a.Title,b.SendName as Name2,b.AddTime,c.Name
from
aDisArea as a
join
aForum as b
on
b.DisAreaId=a.Id
join
aMember as c
on
b.SendId=c.Id
where
b.DisAreaId=@DisAreaId
order by
a.AddTime
end
GO

热点排行