0

hello !
how are you all , hope all of you are in great state of health and peace , well i have some questions ,
1- WHAT IS MSSQL TRANSACTIONS .
2- where we use it.
3- Advantages /Disadvantages
4- Any imp information or point which you think it is imp to know about MSSQL TRANSACTIONS .

as i am not good in mssql so please use simple language :P , i have experience of working in mssql about 2 years , i know about , joins , pivot , functions , views , stored procedures ,but this mssql TRANSACTIONS term is new for me.

Waiting for your helpful comments .

Best Regards

3
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by M.Waqas Aslam
2

Transactions are very important in SQL. They provide a way of reverting previous steps of a multi-step operation on the database that causes changes should an error occur.

Imagine this simple, common scenario. You want to represent a sale of items as a header (containing the date and time of the sale, customer details and miscellaneous information regarding the sale as a whole) and several detail lines each representing the quantity and total cost of each item in the sale. If you have 100 different items in your sale, then the total number of records to be inserted in the database is 101 - 1 header record and 100 detail records in two separate tables. What happens if item number 76 has some error when inserting, maybe the price of the item hasn't been set yet? Without a transaction in place, you would have inserted the header and 75 correct detail records, leaving you with erroneous data in your database. Using a transaction we can "ROLLBACK" the transaction, leaving the database the way it was before we began inserting our records for the sale.

I hope this helps you understand where transactions are useful.

Votes + Comments
awesome way to explain , simple and effective example.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.