孤独的猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

create table testTop

(
 value int primary key
)

--可以一次插入顶部的多条记录

insert top(5) into testTop 
select *
from (select 1 as value union select 2 union select 3 union select 4
   union select 5 union select 6 union select 7) as sevenRows
go 

 

select * from testTop

update top(2) testTop

set value=value * 100 delete top(3) testTop

 

--可以动态设定top的参数

declare @rowsToReturn int
select  @rowsToReturn=10
select Top(@rowsToReturn) *
from HumanResources.Employee

posted on 2012-11-11 10:34  孤独的猫  阅读(311)  评论(0编辑  收藏  举报