create table #临时表(
列名...
)
while(@j<@i+1)
begin
insert into #临时表(列名....)
select top 5 BL.BookID,BL.BookName,BL.ClickNum,BL.Price,BC.BookCategoryName from BookList as BL,BookCategory as BC
where BL.BookCategoryID=@j and BC.BookCategoryID=@j
order by BL.ClickNum desc
set @j=@j+1
end