{"id":35306,"date":"2019-10-31T22:03:32","date_gmt":"2019-10-31T19:03:32","guid":{"rendered":"https:\/\/prohoster.info\/blog\/perenos-dannyh-bekapa-novoj-versii-ms-sql-server-na-bolee-staruyu-versiyu\/"},"modified":"2020-12-15T02:10:03","modified_gmt":"2020-12-15T00:10:03","slug":"perenos-dannyh-bekapa-novoj-versii-ms-sql-server-na-bolee-staruyu-versiyu","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/perenos-dannyh-bekapa-novoj-versii-ms-sql-server-na-bolee-staruyu-versiyu","title":{"rendered":"Transferring backup data from a new version of MS SQL Server to an older version.","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<h2>Background<\/h2>\n<p>Once, to reproduce a bug, I needed a backup of the production database.<\/p>\n<p>To my surprise, I encountered the following limitations:<\/p>\n<ol>\n<li>The database backup was made using version <i>SQL Server 2016<\/i> and was not compatible with my <i>SQL Server 2014<\/i>.<\/li>\n<li>My work computer had <i>Windows 7<\/i>, so I couldn\u2019t upgrade <i>SQL Server<\/i> to version 2016.<\/li>\n<li>The supported product was part of a larger system with a heavily interlinked legacy architecture and also accessed other products and databases, so deploying it on another station could take a very long time.<\/li>\n<\/ol>\n<p>Given the above, I concluded that it was time for non-standard workaround solutions.<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<h2>Data Recovery from Backup<\/h2>\n<p>I decided to use a virtual machine <noindex><a rel=\"nofollow\" href=\"https:\/\/www.virtualbox.org\/\">Oracle VM VirtualBox<\/a><\/noindex> with Windows 10 (a test image can be obtained for the Edge browser <noindex><a rel=\"nofollow\" href=\"https:\/\/developer.microsoft.com\/en-us\/microsoft-edge\/tools\/vms\/\">from here<\/a><\/noindex>). SQL Server 2016 was installed on the virtual machine, and the application database was restored from the backup (<noindex><a rel=\"nofollow\" href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/relational-databases\/backup-restore\/restore-a-database-backup-using-ssms\">the instruction<\/a><\/noindex>).<\/p>\n<h2>Setting Up Access to SQL Server on the Virtual Machine<\/h2>\n<p>Next, it was necessary to take some steps to enable external access to SQL Server:<\/p>\n<ol>\n<li>For the firewall, add a rule to allow requests on port <i>1433<\/i>.<\/li>\n<li>Ideally, access to the server should not go through Windows authentication but via SQL using a login and password (it's easier to set up access). However, in this case, do not forget to enable SQL authentication in the properties of SQL Server.<\/li>\n<li>In the SQL Server user settings on the <i>User Mapping<\/i> tab, specify the user role for the restored database as <i>db_securityadmin.<\/i>.<\/li>\n<\/ol>\n<h2>Data Transfer<\/h2>\n<p>The actual data transfer consists of two stages:<\/p>\n<ol>\n<li>Transferring the data schema (tables, views, stored procedures, etc.)<\/li>\n<li>Transferring the actual data.<\/li>\n<\/ol>\n<h3>Transferring the Data Schema<\/h3>\n<p>We perform the following operations:<\/p>\n<ol>\n<li>Select <i>Tasks -&gt; Generate Scripts<\/i> for the database being transferred.<\/li>\n<li>Select the objects needed for transfer or leave the default value (in this case, scripts for all database objects will be created).<\/li>\n<li>Specify the settings for saving the script. It\u2019s most convenient to save the script in a single file in Unicode encoding. This way, if something goes wrong, there\u2019s no need to repeat all the steps.<\/li>\n<\/ol>\n<p>After saving the script, it can be executed on the source SQL Server (the older version) to create the required database.<\/p>\n<p><b>Attention:<\/b> After executing the script, it is necessary to check the compliance of the database settings from the backup with those from the database created by the script. In my case, the script was missing a setting for COLLATE, which led to failures during data transfer and required complicated workarounds to recreate the database using the augmented script.<\/p>\n<h3>Data Transfer<\/h3>\n<p>Before transferring data, all constraints on the database must be disabled:<\/p>\n<pre><code class=\"sql\">EXEC sp_msforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT all'<\/code><\/pre>\n<p>Data transfer is carried out using the data import wizard. <i>Tasks -&gt; Import Data<\/i> to the SQL Server where the database created by the script is located:<\/p>\n<ol>\n<li>We specify the connection settings to the source (SQL Server 2016 on a virtual machine). I used Data Source <i>SQL Server Native Client<\/i> and the aforementioned SQL authentication.<\/li>\n<li>We provide connection settings to the destination (SQL Server 2014 on the host machine).<\/li>\n<li>Next, we configure mapping. It is necessary to select all <b>not read-only<\/b> objects (for example, views do not need to be selected). As additional options, you should select <i>\"Allow identity insert\"<\/i>, if such are used.<br \/>\n<b>Attention:<\/b> if when trying to highlight multiple tables and set their property <i>\"Allow identity insert\"<\/i> the property was previously set for at least one of the selected tables, the dialog will indicate that the property has already been set for all highlighted tables. This fact can be confusing and lead to transfer errors.<\/li>\n<li>We start the transfer.<\/li>\n<li>We restore constraint checking:\n<pre><code class=\"sql\">EXEC sp_msforeachtable 'ALTER TABLE ? CHECK CONSTRAINT all'<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>If any errors occur, we check the settings, delete the erroneous database, recreate it from the script, make corrections, and repeat the data transfer.<\/p>\n<h2>Conclusion<\/h2>\n<p>This task is quite rare and occurs only due to the above-mentioned constraints. More often, the solution involves upgrading SQL Server or connecting to a remote server if the application's architecture allows it. However, no one is immune from legacy code and poorly executed development. I hope you won't need this guide, but if you do, it will help save a lot of time and nerves. Thank you for your attention!<\/p>\n<h2>List of sources used<\/h2>\n<ul>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/dba.stackexchange.com\/questions\/43065\/how-do-i-deal-with-fk-constraints-when-importing-data-using-dts-import-export-wi\">How do I deal with FK constraints when importing data using DTS Import\/Export Wizard?<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/www.sqlservercentral.com\/forums\/topic\/the-column-column-2-cannot-be-processed-because-more-than-one-code-page-65001-and-1252-are-specified-for-it\">The column \"Column 2\" cannot be processed because more than one code page (65001 and 1252) are specified for it.<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/stackoverflow.com\/questions\/37616521\/how-can-i-connect-to-sqlserver-running-on-virtualbox-from-my-host-macbook\">How can I connect to SQL Server running on VirtualBox from my host Macbook.<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/blog.sqlauthority.com\/2010\/04\/04\/sql-server-enable-identity-insert-import-expert-wizard\/\">SQL SERVER \u2013 Enable Identity Insert \u2013 Import Expert Wizard<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/www.liquidweb.com\/kb\/troubleshooting-microsoft-sql-server-error-18456-login-failed-user\/\">Troubleshooting Microsoft SQL Server Error 18456, Login failed for user<\/a><\/noindex><\/li>\n<\/ul>\n<p>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/455934\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f \u041a\u0430\u043a-\u0442\u043e \u0440\u0430\u0437 \u0434\u043b\u044f \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0431\u0430\u0433\u0430 \u043c\u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0441\u044f \u0431\u044d\u043a\u0430\u043f production-\u0431\u0430\u0437\u044b. \u041a \u043c\u043e\u0435\u043c\u0443 \u0443\u0434\u0438\u0432\u043b\u0435\u043d\u0438\u044e \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438: \u0411\u044d\u043a\u0430\u043f \u0431\u0430\u0437\u044b \u0431\u044b\u043b \u0441\u0434\u0435\u043b\u0430\u043d \u043d\u0430 \u0432\u0435\u0440\u0441\u0438\u0438 SQL Server 2016 \u0438 \u043d\u0435 \u0431\u044b\u043b \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c \u0441 \u043c\u043e\u0435\u0439 SQL Server 2014. \u041d\u0430 \u043c\u043e\u0435\u043c \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u041e\u0421 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430\u0441\u044c Windows 7, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043d\u0435 \u043c\u043e\u0433 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c SQL Server \u0434\u043e \u0432\u0435\u0440\u0441\u0438\u0438 [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-35306","post","type-post","status-publish","format-standard","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f \u041a\u0430\u043a-\u0442\u043e \u0440\u0430\u0437 \u0434\u043b\u044f \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0431\u0430\u0433\u0430 \u043c\u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0441\u044f \u0431\u044d\u043a\u0430\u043f production-\u0431\u0430\u0437\u044b.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/perenos-dannyh-bekapa-novoj-versii-ms-sql-server-na-bolee-staruyu-versiyu\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u041f\u0435\u0440\u0435\u043d\u043e\u0441 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u044d\u043a\u0430\u043f\u0430 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 MS SQL Server \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0430\u0440\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f \u041a\u0430\u043a-\u0442\u043e \u0440\u0430\u0437 \u0434\u043b\u044f \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0431\u0430\u0433\u0430 \u043c\u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0441\u044f \u0431\u044d\u043a\u0430\u043f production-\u0431\u0430\u0437\u044b.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/perenos-dannyh-bekapa-novoj-versii-ms-sql-server-na-bolee-staruyu-versiyu\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-10-31T19:03:32+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-12-15T00:10:03+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47Migrating backup data from a new version of MS SQL Server to an older version | ProHoster","description":"Background Once, to reproduce a bug, I needed a backup of the production database.","canonical_url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/perenos-dannyh-bekapa-novoj-versii-ms-sql-server-na-bolee-staruyu-versiyu","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u041f\u0435\u0440\u0435\u043d\u043e\u0441 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u044d\u043a\u0430\u043f\u0430 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 MS SQL Server \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0430\u0440\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e | ProHoster","og:description":"\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f \u041a\u0430\u043a-\u0442\u043e \u0440\u0430\u0437 \u0434\u043b\u044f \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0431\u0430\u0433\u0430 \u043c\u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0441\u044f \u0431\u044d\u043a\u0430\u043f production-\u0431\u0430\u0437\u044b.","og:url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/perenos-dannyh-bekapa-novoj-versii-ms-sql-server-na-bolee-staruyu-versiyu","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-10-31T19:03:32+00:00","article:modified_time":"2020-12-15T00:10:03+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"35306","title":null,"description":"","keywords":"","keyphrases":null,"primary_term":null,"canonical_url":"","og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-01-21 22:44:19","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-03-01 02:06:24","updated":"2026-01-21 22:44:19","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/35306","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=35306"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/35306\/revisions"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=35306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=35306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=35306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}