表中增加一个读取标志的字段,为1表示已经读取,为0表示未读取
然后用类似下面的语句来读取数据,id是信息表的主键:declare @id int
select top 1 @id=id from 信息表 where 标志=0 order by newid()
if @@rowcount=0
begin
update 信息表 set 标志=0
select top 1 @id=id from 信息表 order by newid()
end
update 信息表 set 标志=1 where id=@id
select * from 信息表 where id=@id
然后用类似下面的语句来读取数据,id是信息表的主键:declare @id int
select top 1 @id=id from 信息表 where 标志=0 order by newid()
if @@rowcount=0
begin
update 信息表 set 标志=0
select top 1 @id=id from 信息表 order by newid()
end
update 信息表 set 标志=1 where id=@id
select * from 信息表 where id=@id
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货