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 :: pad zero sql server 
Sql :: postgresql add column 
Sql :: how to change a collumn name in sql 
Sql :: sql waitfor 
Sql :: oracle timestamp to date 
Sql :: sql server output parameter 
Sql :: mysql show all table from database 
Sql :: inner join update 
Sql :: mysqldump ignore table 
Sql :: sql query to get the number of rows in a table 
Sql :: mysql show views 
Sql :: mysql search table in all databases 
Sql :: mysql terminal run sql file 
Sql :: default constraint in ms sql 
Sql :: read all columns of a table sql 
Sql :: oracle running queries sql 
Sql :: connect mysql command line 
Sql :: sql sum by column 
Sql :: codigo crear tablas sql server 
Sql :: postgres extract day from date 
Sql :: getdate function in postgresql 
Sql :: How to pass password to mysql command line 
Sql :: create user mariadb 
Sql :: Postgres - Login and connect as default user 
Sql :: activate event scheduler mariadb 
Sql :: sql inner join with where clause 
Sql :: how to create external table in hive 
Sql :: rename column in table sql 
Sql :: how to select an index in oracle sql 
Sql :: mysql select row with min date 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =