16 How to rollback a query in SQL

Поділитися
Вставка
  • Опубліковано 21 січ 2025

КОМЕНТАРІ • 56

  • @fantooshh
    @fantooshh 3 роки тому +3

    really helpful brother ahmed, jazakallah khair... kindly share these types of tips in the future also as it will help new dba's in many ways.

    • @learnssis
      @learnssis  3 роки тому +1

      Sure sure, will do. Thanks.

  • @abdullahquhtani4247
    @abdullahquhtani4247 3 роки тому +1

    Thank you so much. Highly appreciated.

    • @learnssis
      @learnssis  3 роки тому

      No problem. You are most welcome Sir.

  • @mahmoudhassanine9905
    @mahmoudhassanine9905 Рік тому +1

    thank you and very helpful
    but if i didn't start the transaction
    how can i rollback ?

    • @learnssis
      @learnssis  Рік тому +1

      If transaction did not happen then it is very hard to rollback. Take a look at this example to do this.
      stackoverflow.com/questions/16945254/how-to-perform-sql-roll-back-from-transaction-logs

  • @indrajitchakraborty5780
    @indrajitchakraborty5780 2 роки тому +1

    How do I rollback a single query among 10 queries inside a single transaction

    • @learnssis
      @learnssis  2 роки тому +1

      The concept of transaction is that either all queries in a transaction will be committed or all queries in a transaction will be rolled back, you can't rollback specific query and commit others in a single transaction. you would need to create separate transaction for each query if you want to rollback a single query.

  • @lovishgoyal2814
    @lovishgoyal2814 5 місяців тому

    is the transaction stage saved so that we can roleback later? What I mean, lets suppose run the wrong script on production and after couplr of hours or days, can we roleback particular transaction from transaction name or stage or any reference of that transaction?

    • @learnssis
      @learnssis  5 місяців тому

      In SQL Server, transactions are typically not saved in a way that allows you to rollback a particular transaction days or hours later after it has been committed. Once a transaction is committed, it is permanent, and SQL Server does not maintain a "save point" that allows for rolling back the transaction at a later time.

  • @heliophilekota5732
    @heliophilekota5732 2 роки тому +1

    Sir in case we did not back up in that case how to undo

    • @learnssis
      @learnssis  2 роки тому

      I have never tried it but can you check below link and see if this helps you
      www.sqlshack.com/recovering-data-from-the-sql-server-transaction-log/

  • @bhanukalia356
    @bhanukalia356 Рік тому

    what if we delete rows without using begin tran , then can we recover records?

    • @learnssis
      @learnssis  Рік тому +1

      I think from transaction log we can recover it but I never tried that.

    • @bhanukalia356
      @bhanukalia356 Рік тому

      @@learnssis ok let me also check , where i can find transactions log?

    • @learnssis
      @learnssis  Рік тому

      @@bhanukalia356Check this URL
      www.linkedin.com/pulse/steps-recover-deleted-data-from-sql-table-using-transaction-/
      You can do google and you will find tons of tutorials on internet on this topic.

  • @guillaumezeler6779
    @guillaumezeler6779 Рік тому

    thank you man !! you helped me a lot :D

  • @nagendrababu7271
    @nagendrababu7271 3 роки тому +1

    Really informative👏🏻

    • @learnssis
      @learnssis  3 роки тому

      Glad you liked the video.

  • @tsvetelinzlatarev6390
    @tsvetelinzlatarev6390 2 роки тому

    Good job! Very helpful!

    • @learnssis
      @learnssis  2 роки тому +1

      You are most welcome.

  • @datadevx
    @datadevx Рік тому

    hello sir , could you please tell which mic you are using and how did you make such clear audio for video . this will be very helpful to me , thank you so much .

    • @learnssis
      @learnssis  Рік тому

      You are the first person who is saying that the audio quality of the video is good. I am using the very basic Boya mic which is of around 750 rupees. I bought it from Amazon.
      Boya ByM1 Auxiliary Omnidirectional Lavalier Condenser Microphone with 20ft Audio Cable (Black)

  • @claw2354
    @claw2354 9 місяців тому

    What if we drop a table?

    • @learnssis
      @learnssis  9 місяців тому

      If you started a transaction and then if you dropped the table, but later you did rollback, then the deleted table will be restored.

  • @amitkumar-rv6ow
    @amitkumar-rv6ow 2 роки тому

    Same email not save SQL query ?

    • @learnssis
      @learnssis  2 роки тому

      Sorry did not get you ?

  • @warrenlucillo6230
    @warrenlucillo6230 8 місяців тому

    VERY INFORMATIVE

  • @catulopsae
    @catulopsae 2 роки тому

    You are so good explaining

    • @learnssis
      @learnssis  2 роки тому

      Thank you so much catusae.

  • @buddhikaperera5716
    @buddhikaperera5716 4 місяці тому

    thank . this really help me

    • @learnssis
      @learnssis  4 місяці тому

      Glad to know that it helped you.

  • @rakeshthakur9403
    @rakeshthakur9403 2 роки тому

    Thank you so much for this video

  • @mahasona5075
    @mahasona5075 8 місяців тому

    Thank you so much 😍

    • @learnssis
      @learnssis  8 місяців тому +1

      You are welcome Mahasona.

  • @mehmath
    @mehmath 2 роки тому

    NEAT!

  • @mak4rno
    @mak4rno Рік тому

    Nice bro can you do it in english next time pls

    • @learnssis
      @learnssis  Рік тому

      I think this is in English right ?

  • @sqltechzpestechz7053
    @sqltechzpestechz7053 Рік тому

    Thank you

  • @MovikaVlogs
    @MovikaVlogs 2 роки тому

    Did not work

    • @learnssis
      @learnssis  2 роки тому

      It will work if you started a transaction before deleting the data.

  • @davidlp3019
    @davidlp3019 Рік тому

    Update statements scare the shit out of me. Do a select first lol. Colleague almost fucked the production database at work by missing the where clause. 😂 Didn't start a transaction either.

    • @learnssis
      @learnssis  Рік тому +1

      Yeah it is a pain to loose the data when we miss to put the where clause.

  • @nooruddinghani4339
    @nooruddinghani4339 Рік тому

    helpful

  • @sreejithr.g.8151
    @sreejithr.g.8151 Рік тому

    for me didnt worked

    • @learnssis
      @learnssis  Рік тому +1

      First execute
      begin tran
      then do whatever update or delete you want to do.
      now, run
      rollback tran
      All the changes will be rollbacked. Let me know if it still does not works.

    • @sreejithr.g.8151
      @sreejithr.g.8151 Рік тому

      @@learnssis thnaks for the response..ya it did worked..but i cant figure out then whats the real purpose of this rollback..we dont write a query knowing that we are going to make a mistake right...so what if we missed to apply a 'begin trans' and performed a query and wanted to undo

    • @engineersadda5550
      @engineersadda5550 Рік тому

      @@learnssis not working tran command in sqlworkbench any other options..

    • @learnssis
      @learnssis  Рік тому +1

      @@engineersadda5550 This is for SQL Server not for MySQL.

    • @aravindhanrk8709
      @aravindhanrk8709 8 місяців тому

      Qqlllllqllllll​@@learnssis