Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 is there a way to create a lock

Author  Topic 

bfoster
Starting Member

30 Posts

Posted - 2008-06-09 : 12:02:45
We have transaction table, and we want to make sure that when we query the balance in an account that another process isn't able to enter a transaction on the same account until we are done with our transaction.

This is a simplified version of the current code:

BEGIN TRANSACTION

SELECT @CurrentBalance = dbo.GetAccountBalanceAsOfDate(@AccountId, GETDATE())

IF (@Debit <= @CurrentBalance)
BEGIN
INSERT INTO dbo.Transactions() VALUES()
END

COMMIT TRANSACTION

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-09 : 13:52:45
Read about transaction isolation levels in books online
Go to Top of Page
   

- Advertisement -