Transaction Management Lab Material
Transaction Management Lab Material
Tools and Services: Includes tools for data management, development, and
business intelligence.
Software Installation
Page 1 of 8
1. License Terms: Accept the license terms and click “Next.”
2. Feature Selection: Select the features you want to install (e.g., Database
Engine Services, SQL Server Replication).
4. Server Configuration: Set up the SQL Server services and specify the
authentication mode (Windows Authentication or Mixed Mode).
o Once the download is complete, locate the installer file (e.g., SSMS-
Setup-ENU.exe) in your downloads folder.
o The installation wizard will guide you through the setup process.
Accept the license terms and click “Install”.
o The installer will proceed to install SSMS. This may take a few minutes.
Page 2 of 8
After installation, you can launch SSMS from the Start menu or by searching for
“SQL Server Management Studio”.
2. In the “Connect to Server” dialog, enter the server name and authentication
details.
o You can find SSMS in the Start menu or by searching for “SQL Server
Management Studio”.
o Server name: Enter the name of your SQL Server instance. This could
be localhost for a local instance, or a network name/IP address for a
remote server.
o Once you’ve entered the necessary details, click the “Connect” button
to establish a connection to your SQL Server instance.
Page 3 of 8
II. Transaction Management Lab Material
1. Accounts Table
2. Inventory Table
3. Orders Table
Page 4 of 8
4. Customers Table
Example:
BEGIN TRANSACTION;
-- Your SQL statements here
2.3 Committing or Rolling Back
To save the changes made during the transaction, use the COMMIT
statement. To undo the changes, use the ROLLBACK statement.
Example:
Page 5 of 8
BEGIN TRANSACTION;
-- Insert a new record
INSERT INTO Customers (Name, Age) VALUES ('Alice', 30);
-- Check if the insertion was successful
IF @@ERROR = 0
COMMIT TRANSACTION;
ELSE
ROLLBACK TRANSACTION;BEGIN
Example:
More Examples
SQL Code:
Page 6 of 8
BEGIN TRANSACTION;
-- Deduct amount from source account
UPDATE Accounts SET Balance = Balance - 100 WHERE AccountID
= 1;
-- Add amount to destination account
UPDATE Accounts SET Balance = Balance + 100 WHERE AccountID
= 2;
-- Check for errors
IF @@ERROR = 0
COMMIT TRANSACTION;
ELSE
ROLLBACK TRANSACTION;
SQL Code:
Page 7 of 8
ELSE
ROLLBACK TRANSACTION 'OrderProcessing';
Page 8 of 8