SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE Accounts ( account_id INT PRIMARY KEY IDENTITY(1,1), customer_id INT NOT NULL, balance DECIMAL(18,2) ); INSERT INTO Accounts (customer_id, balance) VALUES (1, 500), (2, 500); SELECT * FROM Accounts; BEGIN TRANSACTION; SELECT * FROM Accounts WITH (UPDLOCK, HOLDLOCK) WHERE account_id = 1; UPDATE Accounts SET balance = balance - 500 WHERE account_id = 1; COMMIT TRANSACTION; SELECT * FROM Accounts;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear