CREATE PROCEDURE [c_readtop] @eachrow int=10 AS
declare @tmpcat varchar(16)
create table #tmp_result (arid int,cat2 varchar(16),title varchar(100),upday datetime)
declare rt_cursor cursor
for select cat2 from category where cat1='电脑手册' and catl=2
open rt_cursor
fetch from rt_cursor into @tmpcat
while @@fetch_status=0
Begin
set rowcount @eachrow
Insert into #tmp_result (arid,cat2,title,upday) Select top 10 arid,cat2,title,upday from article as a
left join category as b on a.sortid=b.catid where b.cat1='电脑手册' and b.cat2=@tmpcat order by upday desc
fetch from rt_cursor into @tmpcat
End
select * from #tmp_result
drop table #tmp_result
close rt_cursor
deallocate rt_cursor
CREATE PROCEDURE [c_readtop] @eachrow int=10 AS
declare @tmpcat varchar(16)
set nocount on
create table #tmp_result (arid int,cat2 varchar(16),title varchar(100),upday datetime)
declare rt_cursor cursor
for select cat2 from category where cat1='电脑手册' and catl=2
open rt_cursor
fetch from rt_cursor into @tmpcat
while @@fetch_status=0
Begin
set rowcount @eachrow
Insert into #tmp_result (arid,cat2,title,upday) Select top 10 arid,cat2,title,upday from article as a
left join category as b on a.sortid=b.catid where b.cat1='电脑手册' and b.cat2=@tmpcat order by upday desc
fetch from rt_cursor into @tmpcat
End
set nocount off
select * from #tmp_result
drop table #tmp_result
close rt_cursor
deallocate rt_cursor