Search
 
SCRIPT & CODE EXAMPLE
 

SQL

begin transaction in sql

BEGIN TRANSACTION [Tran1]

  BEGIN TRY

      INSERT INTO [Test].[dbo].[T1] ([Title], [AVG])
      VALUES ('Tidd130', 130), ('Tidd230', 230)

      UPDATE [Test].[dbo].[T1]
      SET [Title] = N'az2' ,[AVG] = 1
      WHERE [dbo].[T1].[Title] = N'az'

      COMMIT TRANSACTION [Tran1]

  END TRY

  BEGIN CATCH

      ROLLBACK TRANSACTION [Tran1]

  END CATCH  
Comment

begin transaction sql

-- It is Transaction Control Language(TCL)
-- case1 (temporary)
BEGIN TRANSACTION
-- perform DML operation i.e. INSERT, UPDATE, DELETE
ROLLBACK -- goes to previous state 

-- case2 (permanent)
BEGIN TRANSACTION
-- perform DML operation i.e. INSERT, UPDATE, DELETE
COMMIT -- Transaction is executed and hence change is done permanently
Comment

PREVIOUS NEXT
Code Example
Sql :: Get Minimum from multiple columns sql 
Sql :: delete top N rows in sql 
Sql :: mysql query to check record exists in database table or not 
Sql :: order by oracle 
Sql :: db.Database.SqlQuery 
Sql :: how to get id of last inserted row in mysql 
Sql :: random name function in mysql for nvarchar 
Sql :: get name of day in sql 
Sql :: install postgresql centos 5 
Sql :: mysql how to store lat,lng 
Sql :: mysql average of multiple columns 
Sql :: grant all privileges on a db 
Sql :: sql date get month 
Sql :: mysql else if 
Sql :: date between in mysql 
Sql :: change database name psql 8 
Sql :: snowflake datetrunc month 
Sql :: creating a table in sql 
Sql :: select count 
Sql :: enable constraint in sql 
Sql :: sql get last inserted row 
Sql :: delete join select from one table based on multiple values 
Sql :: select last row in sql 
Sql :: how to get the date from datetime in mysql 
Sql :: vowels in sql 
Sql :: how to combine first and last nae into one columb sql 
Sql :: how to copy data in sql 
Sql :: oracle apex warning message 
Sql :: how to put value in variable mysql 
Sql :: how to insert multiple rows in sql 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =