What Is Savepoint In SQL?
Answers (1)
Add Answersavepoints offer a mechanism to roll back portions of transactions. Within SQL Server, you can create a savepoint by using the SAVE transaction savepoint_name statement. Later, you run a ROLLBACK transaction savepoint_name statement to roll back to the savepoint instead of rolling back to the start of the transaction.
Syntax :
SAVEPOINT Yoursavepoint_name;
Example:
CREATE TABLE emp_data (no NUMBER(3), name VARCHAR(50), code VARCHAR(12) ); //Table created. SAVEPOINT table_create; //Savepoint created. insert into emp_data VALUES(1,'raj', '123'); //1 row created. SAVEPOINT insert_1; //new savepoint create //Savepoint created. insert into emp_data VALUES(2,'mihir', '524'); //1 row created. SAVEPOINT insert_2; //Savepoint created. SELECT * FROM emp_data; //Output NO NAME CODE ---------- ------------------------------ ------------ 1 raj 123 2 mihir 524