我怎么把查出的字段放在一个临时表里面?

2024-12-04 20:49:40
推荐回答(1个)
回答(1):

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