Transaction and Stored Procedure in SqlServer
Explain difference between Transaction and Stored Procedure ?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 17, 2011, 10:01 AM EDT
You use TRANSACTIONS when you want to explicitly COMMIT or ROLLBACK your activity whereas stored procedure does explicit commits and does not perform in a group unless specified. For example if following statement is in the stored procedure:
INSERT INTO TABLEA;
UPDATE TABLEB;
and if UPDATE fails than the INSERT into TABLEA will be commited in the database and if you wrap this thing in the TRANSACTION like below:
BEGIN TRANS
INSERT INTO TABLEA;
UPDATE TABLEB;
COMMIT;
It will rollback if line 2 UPDATE fails.
Please do not forget to mark "Accepted Answer".
Prabhu RajaRank #861 · 2.6K reputationPosted Oct 18, 2011, 2:18 AM EDT
A transaction is a logical unit of work that contains one or more SQL statements.A transaction ends when it is committed or rolled back, either explicitly with a COMMIT or ROLLBACK statement or implicitly when a DDL statement is issued.
Stored procedures contains one or more SQL statements that are precomplied. This is simliar to functions or procedures in any programming languages.