???????
??????????????????????????????????????????????д????????????????????????????????????????????м??????????SQL Server?й??????????????????е???????е??????????д???????????????????
????SQL Server???????????????????
???????????????ж????????????????????儼???????????儼??????????????????????????????????????????????????????????????????????????????????????????????????????????????????ú????o?????????????????????????????????????????????????
CREATE TABLE Test (
Id    INT IDENTITY(1?? 1) NOT NULL PRIMARY KEY??
Other VARCHAR(100))
GO
????????????????????????????
DECLARE  @counter INT
SELECT @counter = 1
WHILE (@counter <= 10)
BEGIN
INSERT INTO Test
(Other)
SELECT 'other action' + CAST(@counter AS VARCHAR)
SELECT @counter = @counter + 1
END

?????????????????????????????SQL???
DECLARE @queueid INT
BEGIN TRAN TRAN1
SELECT TOP 1 @queueid = Id
FROM Test
PRINT 'processing queueid # ' + CAST(@queueid AS VARCHAR)
WAITFOR DELAY '00:00:10'
DELETE FROM Test
WHERE Id = @queueid
COMMIT
??????????????????????????????????????С?

??????????????????????????????????????????????????????????????SQL Server????????????????????????????????????????????Ч?????????????м?????????????????????£?
DECLARE @queueid INT
BEGIN TRAN TRAN1
SELECT TOP 1 @queueid = Id
FROM Test WITH (updlock)
PRINT 'processing queueid # ' + CAST(@queueid AS VARCHAR)
WAITFOR DELAY '00:00:10'
DELETE FROM Test
WHERE Id = @queueid
COMMIT

???????????????????????????????????????????????????????????????????????????????е???????????????????????????????????????????????????????????SQL Server????????READPAST???????????SQL Server???????????????????У??????????????????????????????????????????????????£?
DECLARE @queueid INT
BEGIN TRAN TRAN1
SELECT TOP 1 @queueid = Id
FROM Test WITH (updlock)
BEGIN TRAN TRAN1
SELECT TOP 1 @queueid = Id
FROM Test WITH (UPDLOCK?? READPAST)
PRINT 'processing queueid # ' + CAST(@queueid AS VARCHAR)
WAITFOR DELAY '00:00:10'
DELETE FROM Test
WHERE Id = @queueid
COMMIT
PRINT 'processing queueid # ' + CAST(@queueid AS VARCHAR)
WAITFOR DELAY '00:00:10'
DELETE FROM Test
WHERE Id = @queueid
COMMIT
???????UPDLOCK+READPAST?????y?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????£?
SET NOCOUNT ON
DECLARE @queueid INT
WHILE (SELECT COUNT(*) FROM Test WITH (updlock?? readpast)) >= 1
BEGIN
BEGIN TRAN TRAN1
SELECT TOP 1 @queueid = Id
FROM Test WITH (updlock?? readpast)
PRINT 'processing queueid # ' + CAST(@queueid AS VARCHAR)
WAITFOR DELAY '00:00:10'
DELETE FROM Test
WHERE Id = @queueid
COMMIT
END

???????
????????????????????????SQL Server????β??????????????????????????????????????????????????????????????????кθ????