My interviewer asked me Question that i am inserting 10 rows in database table and in some 5th row i find the some trouble then how can i roll back all the records?
Please let me know how can i do this
My interviewer asked me Question that i am inserting 10 rows in database table and in some 5th row i find the some trouble then how can i roll back all the records?
Please let me know how can i do this
Assuming all occur within the same transaction, use the ROLLBACK
command.
Before you insert the rows
BEGIN TRANSACTION TransactionName
[Insert Rows]
Then either
COMMIT TRANSACTION TransactionName
OR
ROLLBACK TRANSACTION TransactionName
during any problems during the insert.