当前位置: 代码迷 >> Sql Server >> 存储过程中掏出top5,但是只获得了一条
  详细解决方案

存储过程中掏出top5,但是只获得了一条

热度:86   发布时间:2016-04-24 09:00:26.0
存储过程中取出top5,但是只获得了一条
代码如下

ALTER PROCEDURE [dbo].[getaccount]
 @account char(100) output
as
begin tran
select top 5 @account = account from account with(readpast,updlock) where state = '未使用'
update account set state = '已使用' where account = @account

if @@ERROR = 0
commit tran
else rollback tran

求如何解决
------解决思路----------------------
把它插入临时表就可以了