title: Thread safe sql transaction, how to lock a specific row during a transaction?
body: <p>I have a procedure like this:</p>
  
  <pre><code>create procedure Checkout
  @Foo nvarchar(20),
  @cost float
  as
  begin transaction
  
  declare @Bar nvarchar(20);
  select @Bar = Bar from oFoo where Foo = @Foo;
  
  update Foo set gold = gold - @cost where name = @Foo;
  update Bar set gold = gold + @cost where name = @Bar;
  
  delete from oFoo where @Foo = Foo;
  
  commit transaction
  </code></pre>
  
  <p>I need to lock the row with Foo = @Foo from oFoo table during this transaction so that nobody could read/edit/delete it, anybody knows how to do that ?</p>
  
  <p><strong>I am using Microsoft SQL Server 2008</strong></p>