Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Data Management

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

    Search

    XML Feeds

    Google Ads

    « MongoDB: Returning documents where fields are null or not existingWindows and SQL Server 2012 Test Setup »
    comments

    Sometimes you want to quickly see if there are any databases or logs being backed up or restored at this moment. I blogged at one point how you can check how much longer the restore will take here: How much longer will the SQL Server database restore take. The other day someone wanted to know this information for all databases on a server, he wanted to know this for restores as well as backups. The query below will give you that info as well as the percentage that is complete for each operation

    1. SELECT
    2.     d.PERCENT_COMPLETE AS [%Complete],
    3.     d.TOTAL_ELAPSED_TIME/60000 AS ElapsedTimeMin,
    4.     d.ESTIMATED_COMPLETION_TIME/60000   AS TimeRemainingMin,
    5.     d.TOTAL_ELAPSED_TIME*0.00000024 AS ElapsedTimeHours,
    6.     d.ESTIMATED_COMPLETION_TIME*0.00000024  AS TimeRemainingHours,
    7.     d.COMMAND as Command,
    8.     s.text as CommandExecuted
    9. FROM    sys.dm_exec_requests d
    10. CROSS APPLY sys.dm_exec_sql_text(d.sql_handle)as s
    11. WHERE  d.COMMAND LIKE 'RESTORE DATABASE%'
    12. or d.COMMAND     LIKE 'RESTORE LOG%'
    13. OR d.COMMAND     LIKE 'BACKUP DATABASE%'
    14. OR d.COMMAND     LIKE 'BACKUP LOG%'
    15. ORDER   BY 2 desc, 3 DESC

    Throw this in a view on your Tools database and you are all set.

    This will probably also be added to SQLCop's informational section

    About the Author

    User bio imageDenis has been working with SQL Server since version 6.5. Although he worked as an ASP/JSP/ColdFusion developer before the dot com bust, he has been working exclusively as a database developer/architect since 2002. In addition to English, Denis is also fluent in Croatian and Dutch, but he can curse in many other languages and dialects (just ask the SQL optimizer) He lives in Princeton, NJ with his wife and three kids.
    Social SitingsTwitterFacebookLinkedInHomePageFlickrLTD RSS Feed
    1115 views
    InstapaperVote on HN

    No feedback yet

    Leave a comment


    Your email address will not be revealed on this site.

    To mislead the spambots.

    Your URL will be displayed.
    (Line breaks become <br />)
    (Name, email & website)
    (Allow users to contact you through a message form (your email will not be revealed.)