Select 记录

 CREATE PROCEDURE GetSendSMS
@str varchar(180) output
AS
BEGIN TRAN
declare  @id bigint
declare  @num varchar(12)
declare  @contt varchar(144)

Select top 1 @id=[id],@num=[Number],@contt=[Content] From [Send] WITH(UPDLOCK, READPAST)  order by id
if @id>0
    begin
        Insert into [sendlog] ([id],[Number],[Content])values(@id,@num,@contt)
        delete from [send] Where id=@id
        set @str=CAST(@id as varchar(11))+'{^}'+@num+'{^}'+@contt
    end
else
    begin
        set @str=' no'
    end
/*print @str
WAITFOR   DELAY '00:00:20'*/
COMMIT TRAN
return @@RowCount

 

 

 

//WITH(UPDLOCK, READPAST) 锁定Select 记录 要在事务中才行

你可能感兴趣的:(delete,insert,delay)