Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL Server 2005 Query Analyzer: What happens when I stop a query before it finishes executing?

SQL Server 2005 Query Analyzer: What happens when I stop a query before it finishes executing?

Scheduled Pinned Locked Moved Database
databasequestionsql-serversysadminannouncement
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rafferty Uy
    wrote on last edited by
    #1

    Hi, Quick question, I run an update statement to update a huge table then I click the Stop/Cancel button. What happens? Does it roll back all previous transactions or does it leave the updated rows as is? Thanks.

    Rafferty

    M S 2 Replies Last reply
    0
    • R Rafferty Uy

      Hi, Quick question, I run an update statement to update a huge table then I click the Stop/Cancel button. What happens? Does it roll back all previous transactions or does it leave the updated rows as is? Thanks.

      Rafferty

      M Offline
      M Offline
      Muhammad Shahid Farooq
      wrote on last edited by
      #2

      Its leave the updated rows. If you want to rollback all previous transactions, use the following before query: Begin Tran

      1 Reply Last reply
      0
      • R Rafferty Uy

        Hi, Quick question, I run an update statement to update a huge table then I click the Stop/Cancel button. What happens? Does it roll back all previous transactions or does it leave the updated rows as is? Thanks.

        Rafferty

        S Offline
        S Offline
        scottgp
        wrote on last edited by
        #3

        First, I would say that it should be easy for you to test that yourself. Second, I just performed that test, and if the update is done by a single statement and that statement is canceled, it appears to be rolled back. Scott

        R 1 Reply Last reply
        0
        • S scottgp

          First, I would say that it should be easy for you to test that yourself. Second, I just performed that test, and if the update is done by a single statement and that statement is canceled, it appears to be rolled back. Scott

          R Offline
          R Offline
          Rafferty Uy
          wrote on last edited by
          #4

          Hi Scott, I did test it, and like you said it appears to be rolled back. Part of me just couldn't believe it so I asked here for more "documentation"-like answers :) But it does appear that if it's a single statement, the query analyzer will treat all the changes as part of one transaction. Thanks.

          Rafferty

          S 1 Reply Last reply
          0
          • R Rafferty Uy

            Hi Scott, I did test it, and like you said it appears to be rolled back. Part of me just couldn't believe it so I asked here for more "documentation"-like answers :) But it does appear that if it's a single statement, the query analyzer will treat all the changes as part of one transaction. Thanks.

            Rafferty

            S Offline
            S Offline
            scottgp
            wrote on last edited by
            #5

            Sorry, I didn't realize you had already tested it. At least our test results seem consistent. :) I did finally find this in the Books Online: Errors During Transaction Processing If a severe error prevents the successful completion of a transaction, SQL Server automatically rolls back the transaction and frees all resources held by the transaction. If the client's network connection to SQL Server is broken, any outstanding transactions for the connection are rolled back when the network notifies SQL Server of the break. If the client application fails or if the client computer goes down or is restarted, this also breaks the connection, and SQL Server rolls back any outstanding connections when the network notifies it of the break. If the client logs off the application, any outstanding transactions are rolled back. Scott

            R 1 Reply Last reply
            0
            • S scottgp

              Sorry, I didn't realize you had already tested it. At least our test results seem consistent. :) I did finally find this in the Books Online: Errors During Transaction Processing If a severe error prevents the successful completion of a transaction, SQL Server automatically rolls back the transaction and frees all resources held by the transaction. If the client's network connection to SQL Server is broken, any outstanding transactions for the connection are rolled back when the network notifies SQL Server of the break. If the client application fails or if the client computer goes down or is restarted, this also breaks the connection, and SQL Server rolls back any outstanding connections when the network notifies it of the break. If the client logs off the application, any outstanding transactions are rolled back. Scott

              R Offline
              R Offline
              Rafferty Uy
              wrote on last edited by
              #6

              Wow, there's the answer I'm looking for! Thanks Scott! :)

              Rafferty

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups