loop through sys.dm_exec_requests for 99% complete?

Last Post 23 Oct 2012 08:59 AM by SQLme. 2 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
SQLme
New Member
New Member

--
23 Oct 2012 05:21 AM

is there a way you can loop through the sys.dm_exec_requests dmv for the percent_complete?

for example i would like to do something like the following:

***************************************
***************************************

if percent_complete > 99 where db_Name(dbid) = 'mydb' and command = 'whatever'
begin
MyStatementHere
end
else
MyOtherStatementHere

***************************************
***************************************

it's the 'looping' part i'm trying to figure out. is there some kind of 'wait for' function?

if someone can point me in the right direction that would be great.
and... as always. thanks for your help. you guys are the pro's so you're faster than google :)
gunneyk
New Member
New Member

--
23 Oct 2012 08:36 AM
I am not sure what you mean by looping since your example seems to target something specific. You can always build a cursor agaisnt a query on the sys.dm_exec_requests since it returns results liek any view or table. If you need help on the syntax of a cursor then take a look in the Template Explorer of SSMS (View-Template Explorer) and under the Ealier Versions node you will see using Cursors.
But with that said keep in mind that there are very few commands that actually populate Percent_complete, Things like backup & restore are the most useful.
SQLme
New Member
New Member

--
23 Oct 2012 08:59 AM
thanks gunny :) i will checkout those resources, and learn more about whats going on here.

much appreciated!


Acceptable Use Policy
---