SQL 新发现的东东

  新建表变量

  declare   @indextable   table(id   int   identity(1,1),   nid   int)  
  insert   @indextable  
  select   2  
  union    
  select   3  
  select   *   from   @indextable  

 

 

 declare @indextable table(id int identity(1,1),nid int)
 set rowcount @endIndex
 insert into @indextable(nid) select ID from News  order by ID desc
 select * from News O,@indextable t where O.ID=t.nid
 and t.id between @startIndex and @endIndex order by t.id

posted @ 2008-07-24 22:55  liuyan  阅读(127)  评论(0编辑  收藏  举报