CREATE TABLE [dbo].[Rss_RssSources](
[SourceId] [int] IDENTITY(1,1) NOT NULL,
[Link] [varchar](1024) NOT NULL
) ON [PRIMARY]
declare @i int
set @i = 1
while @i <10000
begin
select @i = @i +1
insert into [Rss_RssSources] values(newid())
end
create table Rss_RssSourceLock
(
IsLock bit,
MaxSourceId int
)
insert into Rss_RssSourceLock values (0,0)
CREATE PROCEDURE [dbo].[USP_GetRssSources]
AS
BEGIN
if exists(select * from Rss_RssSourceLock with(READPAST) where IsLock = 0)
begin
declare @select_count int
begin tran
update Rss_RssSourceLock set IsLock = 1
if object_id('tempdb..#t') is not null
drop table #t
select top 10 a.* into #t from [Rss_RssSources] as a
inner join Rss_RssSourceLock as b
on a.SourceId > b.MaxSourceId
order by a.[SourceId]
select @select_count = count(*) from #t
update Rss_RssSourceLock set IsLock = 0,MaxSourceId = MaxSourceId + @select_count
select * from #t
commit tran
end
END
分享到:
2008-05-25 19:16
浏览 1110
评论