CREATE PROCEDURE usp_liuyanquery
(
  
     @PageLowerBound INT, 
     @PageUpperBound INT,
     @Answer varchar(
500
)
as
begin

declare @indextable table(id 
int identity(1,1),nid int)  --定义表变量

insert into @indextable(nid) select id from liuyan_T where answer like 
'%'+@Answer+'%' or content  like '%'+@Answer+'%'

select  d.id,d.name,d.type,d.E_mail,d.zhuye,d.qicq,d.content,d.createtime,d.answer,d.Reverter  from liuyan_T  d,
@indextable t where (d.id
=t.nid)
and t.id
>@PageLowerBound and t.id<=@PageUpperBound  order by t.id desc
end

GO
主要就是把你要查询的表生成另一个表
posted on 2006-06-24 10:04  过江  阅读(221)  评论(0编辑  收藏  举报