Tuesday, November 8, 2011

Rollback,Commit,Truncate Example

/* CREATE TABLE */
CREATE TABLE TRUNTEST(ID INT)
/* INSERT TABLE VALUES */
INSERT INTO TRUNTEST  VALUES(5)
/*SELECT TABLE*/
SELECT * FROM TRUNTEST
/* BEFORE SELECT BEGIN TRAN*/
BEGIN TRAN
TRUNCATE TABLE TRUNTEST
SELECT * FROM TRUNTEST
/*TRUNCATE AFTER ROLLBACK TRANSACTION*/
ROLLBACK TRAN
SELECT * FROM TRUNTEST
/*COMMIT TRANSACTION*/
BEGIN TRAN
COMMIT TRAN
SELECT * FROM TRUNTEST

No comments:

Post a Comment