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

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.

commented: awesome way to explain , simple and effective example. +5

thanks sir darkagn and sir pritaeas , for your valuable time . thread is solved :)

Regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.