【发布时间】:2013-03-12 18:35:45
【问题描述】:
在下面的代码中。一次只会执行一个“选择”语句。我希望能够更新任何选定行的“状态”并返回数据。这基本上可以防止在后端处理期间获取相同的记录。
谢谢!
-- Insert statements for procedure here
if(@BatchSize > -1 and @Priority > -1)
begin
Select TOP(@BatchSize) *,ID
From CompingQueue
Where PriorityLevel=@Priority
and Status=35
order by PriorityLevel asc;
end
if(@BatchSize = -1 and @Priority = -1)
begin
Select * From CompingQueue
Where Status=35
order by PriorityLevel asc;
end
if(@BatchSize = -1 and @Priority > -1)
begin
Select * From CompingQueue
WHEre PriorityLevel=@Priority
and Status=35
order by PriorityLevel asc;
end
if(@BatchSize > -1 and @Priority = -1)
begin
Select TOP(@BatchSize) *
From CompingQueue
Where Status=35
order by PriorityLevel asc;
end
--update CompingQueue set Status = 2 where ID=
-- Set the Status Flag for each job
结束
【问题讨论】:
标签: sql sql-server select sql-update