{"id":4710,"date":"2017-04-20T10:50:24","date_gmt":"2017-04-20T17:50:24","guid":{"rendered":"http:\/\/3.209.169.194\/blogs\/paul\/?p=4710"},"modified":"2017-06-06T08:45:29","modified_gmt":"2017-06-06T15:45:29","slug":"sqlskills-sql101-restoring-to-an-earlier-version","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/sqlskills-sql101-restoring-to-an-earlier-version\/","title":{"rendered":"SQLskills SQL101: Restoring to an earlier version"},"content":{"rendered":"<p style=\"text-align: justify;\"><em>As <a href=\"https:\/\/www.sqlskills.com\/blogs\/kimberly\/sqlskills-sql101-stored-procedures\/\" target=\"_blank\" rel=\"noopener noreferrer\">Kimberly blogged about recently<\/a>, SQLskills is embarking on a new initiative to\u00a0blog about basic topics, which we\u2019re calling SQL101. We\u2019ll all be blogging about\u00a0things\u00a0that we often see done incorrectly, technologies used the wrong way,\u00a0or where there are many misunderstandings that lead to serious problems. If you want to find all of our <strong>SQLskills SQL101<\/strong> blog posts, check out\u00a0<a href=\"https:\/\/www.sqlskills.com\/help\/SQL101\" target=\"_blank\" rel=\"noopener noreferrer\">SQLskills.com\/help\/SQL101<\/a>.<\/em><\/p>\n<p style=\"text-align: justify;\">One of the questions I get asked every so often is whether it&#8217;s possible to attach or restore a database to an earlier version of SQL Server. Usually the explanation behind the question is that the person accidentally attached the only copy of their database to a newer version than they wanted, or they were just trying out a pre-release version and now want to put their database back into their production system.<\/p>\n<p style=\"text-align: justify;\">So is this possible? The very simple answer is: No.<\/p>\n<p style=\"text-align: justify;\">SQL Server is down-level compatible but is not up-level compatible. This means you can take a database from an earlier version and attach\/restore it to a newer version (I explained about this in a post <a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/you-can-upgrade-from-any-version-2005-to-any-other-version\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>), but you can&#8217;t go backwards to an earlier version.<\/p>\n<p style=\"text-align: justify;\">Why is this the case?<\/p>\n<p style=\"text-align: justify;\"><strong>Upgrade steps<\/strong><\/p>\n<p style=\"text-align: justify;\">An upgrade, whether intentional or accidental, is a one-way operation and it is extremely difficult to reverse its effects. When you upgrade between versions of SQL Server, a series of upgrade steps are performed on the database. Each step usually involves some physical changes to the database, and each step increases the physical version number of the database.<\/p>\n<p style=\"text-align: justify;\">For example, one of the major changes performed when a database was upgraded from SQL Server 2000 to SQL Server 2005 (yes, old and unsupported, but an easy-to-explain example) was to change the structure of the\u00a0database&#8217;s system catalogs (often called the system tables or database metadata) that hold various metadata about tables, indexes, columns, allocations, and other details regarding the relational and physical structure of the database.<\/p>\n<p style=\"text-align: justify;\">As each of these upgrade steps is performed, the database version number is increased. Here are some examples:<\/p>\n<ul style=\"text-align: justify;\">\n<li class=\"ArticleNormalPara\">SQL Server 2016\u00a0databases have version number 852<\/li>\n<li class=\"ArticleNormalPara\">SQL Server 2014 databases have version number 782<\/li>\n<li class=\"ArticleNormalPara\">SQL Server 2012 databases have version number 706<\/li>\n<li class=\"ArticleNormalPara\">SQL Server 2008 R2 databases have version number 661<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">This version number allows SQL Server to know the last upgrade step performed on the database, and whether the in-use SQL Server version can understand the database being attached\/restored.<\/p>\n<p style=\"text-align: justify;\">Here&#8217;s an example of restoring a SQL Server 2012 database to a SQL Server 2014 server:<\/p>\n<pre class=\"brush: sql; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\r\nRESTORE DATABASE &#x5B;Company2012]\r\nFROM DISK = N'D:\\SQLskills\\Company2012_Full.bak'\r\nWITH REPLACE;\r\nGO\r\n<\/pre>\n<pre class=\"brush: plain; gutter: false; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\r\nProcessed 280 pages for database 'Company', file 'Company' on file 1.\r\nProcessed 3 pages for database 'Company', file 'Company_log' on file 1.\r\nConverting database 'Company' from version 706 to the current version 782.\r\nDatabase 'Company' running the upgrade step from version 706 to version 770.\r\nDatabase 'Company' running the upgrade step from version 770 to version 771.\r\nDatabase 'Company' running the upgrade step from version 771 to version 772.\r\nDatabase 'Company' running the upgrade step from version 772 to version 773.\r\nDatabase 'Company' running the upgrade step from version 773 to version 774.\r\nDatabase 'Company' running the upgrade step from version 774 to version 775.\r\nDatabase 'Company' running the upgrade step from version 775 to version 776.\r\nDatabase 'Company' running the upgrade step from version 776 to version 777.\r\nDatabase 'Company' running the upgrade step from version 777 to version 778.\r\nDatabase 'Company' running the upgrade step from version 778 to version 779.\r\nDatabase 'Company' running the upgrade step from version 779 to version 780.\r\nDatabase 'Company' running the upgrade step from version 780 to version 781.\r\nDatabase 'Company' running the upgrade step from version 781 to version 782.\r\nRESTORE DATABASE successfully processed 283 pages in 0.022 seconds (100.430 MB\/sec).\r\n<\/pre>\n<p><strong>Up-level compatibility (or lack thereof&#8230;)<\/strong><\/p>\n<p>Versions of SQL Server cannot read databases upgraded to more recent versions of SQL Server &#8211; for instance, SQL Server 2012 cannot read a database that&#8217;s been upgraded to SQL Server 2014. This is because older versions do not have the code needed to interpret the upgraded structures and database layout.<\/p>\n<p>Here&#8217;s an example of trying to restore a SQL Server 2014 database to a SQL Server 2012 server:<\/p>\n<pre class=\"brush: sql; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\r\nRESTORE DATABASE &#x5B;Company2014]\r\nFROM DISK = N'D:\\SQLskills\\Company2014_Full.bak'\r\nWITH REPLACE;\r\nGO\r\n<\/pre>\n<pre class=\"brush: plain; gutter: false; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\r\nMsg 3169, Level 16, State 1, Line 51\r\nThe database was backed up on a server running version 12.00.4422. That version is incompatible with this server, which is running version 11.00.5343. Either restore the database on a server that supports the backup, or use a backup that is compatible with this server.\r\nMsg 3013, Level 16, State 1, Line 51\r\nRESTORE DATABASE is terminating abnormally.\r\n<\/pre>\n<p>In earlier versions, the messages weren&#8217;t always quite as nice and easy to understand.<\/p>\n<p style=\"text-align: justify;\">And some people confuse database compatibility level with the database version. Compatibility level has nothing to do with up-level compatibility &#8211; it just changes how some query processor features behave.<\/p>\n<p><strong>Summary<\/strong><\/p>\n<p style=\"text-align: justify;\">The simple thing to bear in mind\u00a0is not to attach the only copy of your database to a newer version. It&#8217;s always better to restore a copy of a database, then you&#8217;ve still got the original database to fall back on, for whatever reason. This applies even if you&#8217;re deliberately performing an upgrade &#8211; I&#8217;d still want to keep the older copy of the database around in case some problem occurs with the upgrade.<\/p>\n<p style=\"text-align: justify;\">If you *have* attached your only copy of the database to a newer version and want to go back to an earlier version, your only option is to script out the database structure, create the database again on the older version, and then transfer all the data from the newer version to the older version. Very tedious.<\/p>\n<p style=\"text-align: justify;\">Hope you found this helpful!<\/p>\n<p style=\"text-align: justify;\"><strong>PS<\/strong> There&#8217;s a comment below asking whether you can move back to an earlier SP or CU. Yes, for user databases, as long as the newer SP\/CU didn&#8217;t change the physical version number (and none of them since 2005 SP2 and 2008 SP2 have done that).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As Kimberly blogged about recently, SQLskills is embarking on a new initiative to\u00a0blog about basic topics, which we\u2019re calling SQL101. We\u2019ll all be blogging about\u00a0things\u00a0that we often see done incorrectly, technologies used the wrong way,\u00a0or where there are many misunderstandings that lead to serious problems. If you want to find all of our SQLskills SQL101 [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,62,108],"tags":[],"class_list":["post-4710","post","type-post","status-publish","format-standard","hentry","category-backuprestore","category-on-disk-structures","category-sql101"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SQLskills SQL101: Restoring to an earlier version - 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\/sqlskills-sql101-restoring-to-an-earlier-version\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQLskills SQL101: Restoring to an earlier version - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"As Kimberly blogged about recently, SQLskills is embarking on a new initiative to\u00a0blog about basic topics, which we\u2019re calling SQL101. We\u2019ll all be blogging about\u00a0things\u00a0that we often see done incorrectly, technologies used the wrong way,\u00a0or where there are many misunderstandings that lead to serious problems. If you want to find all of our SQLskills SQL101 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/sqlskills-sql101-restoring-to-an-earlier-version\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2017-04-20T17:50:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-06-06T15:45:29+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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/sqlskills-sql101-restoring-to-an-earlier-version\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/sqlskills-sql101-restoring-to-an-earlier-version\/\",\"name\":\"SQLskills SQL101: Restoring to an earlier version - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2017-04-20T17:50:24+00:00\",\"dateModified\":\"2017-06-06T15:45:29+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/sqlskills-sql101-restoring-to-an-earlier-version\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/sqlskills-sql101-restoring-to-an-earlier-version\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/sqlskills-sql101-restoring-to-an-earlier-version\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQLskills SQL101: Restoring to an earlier version\"}]},{\"@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":"SQLskills SQL101: Restoring to an earlier version - 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\/sqlskills-sql101-restoring-to-an-earlier-version\/","og_locale":"en_US","og_type":"article","og_title":"SQLskills SQL101: Restoring to an earlier version - Paul S. Randal","og_description":"As Kimberly blogged about recently, SQLskills is embarking on a new initiative to\u00a0blog about basic topics, which we\u2019re calling SQL101. We\u2019ll all be blogging about\u00a0things\u00a0that we often see done incorrectly, technologies used the wrong way,\u00a0or where there are many misunderstandings that lead to serious problems. If you want to find all of our SQLskills SQL101 [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/sqlskills-sql101-restoring-to-an-earlier-version\/","og_site_name":"Paul S. Randal","article_published_time":"2017-04-20T17:50:24+00:00","article_modified_time":"2017-06-06T15:45:29+00:00","author":"Paul Randal","twitter_misc":{"Written by":"Paul Randal","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/sqlskills-sql101-restoring-to-an-earlier-version\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/sqlskills-sql101-restoring-to-an-earlier-version\/","name":"SQLskills SQL101: Restoring to an earlier version - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2017-04-20T17:50:24+00:00","dateModified":"2017-06-06T15:45:29+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/sqlskills-sql101-restoring-to-an-earlier-version\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/sqlskills-sql101-restoring-to-an-earlier-version\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/sqlskills-sql101-restoring-to-an-earlier-version\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"SQLskills SQL101: Restoring to an earlier version"}]},{"@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\/4710","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=4710"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/4710\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=4710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=4710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=4710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}