sql server - Getting info about running update query -


On SQL Server 2008, I have a slow running update query that is working for 3 hours Any way to get any data about this execution (say, how many rows have changed so far or something) (of course, while executing)? So that I can make a decision between canceling the query and optimizing it or finishing it.

Otherwise, have I done something before the execution? If so, the update query whether the first execution to obtain information can be (of course, without performance impact to a large extent)

obvious to a update:
question mentioned uPDATE statement (for example):
Meritaibl SET Col_a update =
'Value1' WHERE col_B = 'value2' in other words, it's a Single query that updates the entire table

What can you do now?

You can try to run a different query to see how many rows (NOLOCK) can be used to update if there is an update statement such as:

  update MyTable set MyField = 'UPDATEDVALUE' where 1 and ID between 10000000  

you can run this:

  sELECT COUNT ( *) with MyTable (NOLOCK) where 1 and 10,000,000 and MyField = 'UPDATEDVALUE'  id between 


what you can do in the future?

You can update in the batch, and the output is as fast as possible. As such say, use a loop to update records in the chunks of 1000 (semi value for the point of explanation). After each update completes the part, the progress print out (assuming you are running it from SSMS) like

  declaration @RowCount set the integer @RowCount = 1 declared @Message VARCHAR ( 500) announced @TotalRowsUpdated integer set @TotalRowsUpdated = 0 while (@RowCount & gt; 0) 1 and 10,000,000 and MyField between the start date TOP (1000) MyTable set MyField = 'UPDATEDVALUE' Where ID & lt; & Gt; 'UPDATEDVALUE' select @RowCount = @@ ROWCOUNT (the GETDATE (as VARCHAR)) @TotalRowsUpdated = @TotalRowsUpdated + @RowCount choose @Message = Cast Set + ':' + cast (as VARCHAR @TotalRowsUpdated) + ' By using the RAISERROR in the record, the total update 'RAISERROR (@ message, 0, 1) with NOWAIT END ensures that the progress messages will be printed immediately if you print instead , The messages are spooled and there is no instant output so that you can make real time progress Can not see. 


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -