{"id":1059,"date":"2008-04-17T01:27:00","date_gmt":"2008-04-17T01:27:00","guid":{"rendered":"\/blogs\/paul\/post\/Search-Engine-QA-18-Whats-the-current-uptime-of-SQL-Server.aspx"},"modified":"2015-06-22T16:41:26","modified_gmt":"2015-06-22T23:41:26","slug":"search-engine-qa-18-whats-the-current-uptime-of-sql-server","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-18-whats-the-current-uptime-of-sql-server\/","title":{"rendered":"Search Engine Q&#038;A #18: What&#8217;s the current uptime of SQL Server?"},"content":{"rendered":"<p><font face=\"Verdana\"><\/p>\n<p>\n<font size=\"2\">Here&#39;s a quickie just before we head off to <\/font><font size=\"2\">SQL Connections<\/font><font size=\"2\"> in Orlando. <\/font>\n<\/p>\n<p>\n<font size=\"2\">On one of the internal MS forums was the question &#8211; how can I tell through T-SQL the last time SQL Server restarted (i.e. the current &#39;uptime&#39;)? The answer relies on the fact that all the background tasks that start when SQL Server starts must record a &#39;login time&#39;. <\/font>\n<\/p>\n<p>\n<font size=\"2\">You can get this from: <\/font>\n<\/p>\n<blockquote dir=\"ltr\" style=\"margin-right: 0px\"><p>\n\t<font color=\"#0000ff\"><\/p>\n<p>\n\t<font face=\"Courier New\" size=\"2\">SELECT<\/font><font face=\"Courier New\"><font size=\"2\"><font color=\"#000000\"> [login_time] <\/font><font color=\"#0000ff\">FROM<\/font><font color=\"#000000\"> sysprocesses <\/font><font color=\"#0000ff\">WHERE<\/font><font color=\"#000000\"> spid <\/font><font color=\"#808080\">=<\/font><font color=\"#000000\"> 1<\/font><\/font><font size=\"2\" color=\"#808080\">;<br \/>\n\t<\/font><\/font><font size=\"2\"><font face=\"Courier New\">GO<\/font> <\/font>\n\t<\/p>\n<p>\t<\/font>\n<\/p><\/blockquote>\n<p dir=\"ltr\">\n<font size=\"2\"><font face=\"Courier New\"><font face=\"Verdana\" color=\"#000000\">Or more simply:<\/font><\/font> <\/font>\n<\/p>\n<blockquote><p>\n\t<font face=\"Courier New\"><font color=\"#0000ff\"><\/p>\n<p>\n\t<font size=\"2\">SELECT<font color=\"#000000\"> <\/font><font color=\"#ff00ff\">MIN<\/font><font color=\"#000000\"> <\/font><font color=\"#808080\">(<\/font><font color=\"#000000\">[login_time]<\/font><font color=\"#808080\">)<\/font><font color=\"#000000\"> <\/font><font color=\"#0000ff\">FROM<\/font><font color=\"#000000\"> sysprocesses<\/font><\/font><font size=\"2\"><font color=\"#808080\">;<br \/>\n\t<\/font>GO <\/font>\n\t<\/p>\n<p>\t<\/font><\/font>\n<\/p><\/blockquote>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">Pretty neat trick! <\/font>\n<\/p>\n<p><\/font><\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">As with the last few conferences, I&#39;ll try to blog every day during SQL Connections under the Conference Questions Pot-Pourri category. <\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">Hope to see a bunch of you there!<\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">PS Some people have suggested that checking the creation date of tempdb will also do the trick. That&#39;s not a *guaranteed* method as PSS could have used T3609 to recover tempdb instead of recreating it (if they&#39;re troubleshooting some tempdb issue). In that case the creation date of tempdb will *not* be the time the server started. Checking the time in sysprocesses is the only infallible method. <\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#39;s a quickie just before we head off to SQL Connections in Orlando. On one of the internal MS forums was the question &#8211; how can I tell through T-SQL the last time SQL Server restarted (i.e. the current &#39;uptime&#39;)? The answer relies on the fact that all the background tasks that start when SQL [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44,78],"tags":[],"class_list":["post-1059","post","type-post","status-publish","format-standard","hentry","category-general","category-search-engine-q-and-a"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Search Engine Q&amp;A #18: What&#039;s the current uptime of SQL Server? - Paul S. Randal<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-18-whats-the-current-uptime-of-sql-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Search Engine Q&amp;A #18: What&#039;s the current uptime of SQL Server? - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"Here&#039;s a quickie just before we head off to SQL Connections in Orlando. On one of the internal MS forums was the question &#8211; how can I tell through T-SQL the last time SQL Server restarted (i.e. the current &#039;uptime&#039;)? The answer relies on the fact that all the background tasks that start when SQL [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-18-whats-the-current-uptime-of-sql-server\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2008-04-17T01:27:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-06-22T23:41:26+00:00\" \/>\n<meta name=\"author\" content=\"Paul Randal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Paul Randal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-18-whats-the-current-uptime-of-sql-server\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-18-whats-the-current-uptime-of-sql-server\/\",\"name\":\"Search Engine Q&A #18: What's the current uptime of SQL Server? - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2008-04-17T01:27:00+00:00\",\"dateModified\":\"2015-06-22T23:41:26+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-18-whats-the-current-uptime-of-sql-server\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-18-whats-the-current-uptime-of-sql-server\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-18-whats-the-current-uptime-of-sql-server\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Search Engine Q&#038;A #18: What&#8217;s the current uptime of SQL Server?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\",\"name\":\"Paul S. Randal\",\"description\":\"In Recovery...\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\",\"name\":\"Paul Randal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"caption\":\"Paul Randal\"},\"sameAs\":[\"http:\/\/3.209.169.194\/blogs\/paul\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Search Engine Q&A #18: What's the current uptime of SQL Server? - Paul S. Randal","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-18-whats-the-current-uptime-of-sql-server\/","og_locale":"en_US","og_type":"article","og_title":"Search Engine Q&A #18: What's the current uptime of SQL Server? - Paul S. Randal","og_description":"Here&#39;s a quickie just before we head off to SQL Connections in Orlando. On one of the internal MS forums was the question &#8211; how can I tell through T-SQL the last time SQL Server restarted (i.e. the current &#39;uptime&#39;)? The answer relies on the fact that all the background tasks that start when SQL [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-18-whats-the-current-uptime-of-sql-server\/","og_site_name":"Paul S. Randal","article_published_time":"2008-04-17T01:27:00+00:00","article_modified_time":"2015-06-22T23:41:26+00:00","author":"Paul Randal","twitter_misc":{"Written by":"Paul Randal","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-18-whats-the-current-uptime-of-sql-server\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-18-whats-the-current-uptime-of-sql-server\/","name":"Search Engine Q&A #18: What's the current uptime of SQL Server? - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2008-04-17T01:27:00+00:00","dateModified":"2015-06-22T23:41:26+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-18-whats-the-current-uptime-of-sql-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-18-whats-the-current-uptime-of-sql-server\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-18-whats-the-current-uptime-of-sql-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"Search Engine Q&#038;A #18: What&#8217;s the current uptime of SQL Server?"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/","name":"Paul S. Randal","description":"In Recovery...","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce","name":"Paul Randal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","caption":"Paul Randal"},"sameAs":["http:\/\/3.209.169.194\/blogs\/paul"],"url":"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/1059","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/comments?post=1059"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/1059\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=1059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=1059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=1059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}