{"id":9100,"date":"2016-10-21T15:07:43","date_gmt":"2016-10-21T13:07:43","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/configure-easily-your-stretch-database\/"},"modified":"2016-10-21T15:07:43","modified_gmt":"2016-10-21T13:07:43","slug":"configure-easily-your-stretch-database","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/configure-easily-your-stretch-database\/","title":{"rendered":"Configure easily your Stretch Database"},"content":{"rendered":"<p>In this blog, I will present you the new Stretch Database feature in SQL Server 2016. It couples your SQL Server On-Premises database with an Azure SQL Database, allowing to stretch data from one ore more tables to Azure Cloud.<br \/>\nThis mechanism offers to use low-cost hard drives available in Azure, instead of fast and expensive local solid state drives. Indeed SQL Database Server resources are solicited during data transfers and during remote queries (and not SQL Server on-premises). <\/p>\n<p>First, you need to enable the &#8220;Remote Data Archive&#8221; option at the instance level. To verify if the option is enabled:<br \/>\n<code>USE master<br \/>\nGO<br \/>\nSELECT name, value, value_in_use, description from sys.configurations where name like 'remote data archive'<\/code><\/p>\n<p>To enable this option at the instance level:<br \/>\n<code><br \/>\nEXEC sys.sp_configure N'remote data archive', '1';<br \/>\nRECONFIGURE;<br \/>\nGO<\/code><\/p>\n<p>Now, you have to link your on-premises database with a remote SQL Database server:<br \/>\n<code>Use AdventureWorks2014;<br \/>\nGO<br \/>\nCREATE MASTER KEY ENCRYPTION BY PASSWORD = 'masterPa$$w0rd'<br \/>\nGO<br \/>\nCREATE DATABASE SCOPED CREDENTIAL Stretch_cred<br \/>\n    WITH IDENTITY = 'dbi' , SECRET = 'userPa$$w0rd' ;<br \/>\nGO<br \/>\nALTER DATABASE AdventureWorks2014<br \/>\n    SET REMOTE_DATA_ARCHIVE = ON<br \/>\n        (<br \/>\n            SERVER = 'dbisqldatabase.database.windows.net' ,<br \/>\n            CREDENTIAL = Stretch_cred<br \/>\n        ) ;<br \/>\nGO<\/code><\/p>\n<p>The process may take some time as it will create a new SQL Database in Azure, linked to your on-premises database. The credential entered to connect to your SQL Database server is defined in SQL Database. Previously you need to secure the credential by a database master key.<\/p>\n<p>To view all the remote databases from your instance:<br \/>\n<code>Select * from sys.remote_data_archive_databases<\/code><\/p>\n<p>Now, if you want to migrate one table from your database ([Purchasing].[PurchaseOrderDetail] in my example), proceed as follows:<br \/>\n<code>ALTER TABLE [Purchasing].[PurchaseOrderDetail]<br \/>\n    SET ( REMOTE_DATA_ARCHIVE ( MIGRATION_STATE = OUTBOUND) ) ; <\/code><\/p>\n<p>Of course repeat this process for each table you want to stretch. You can still access to your data during the migration process.<\/p>\n<p>To view all the remote tables from your instance:<br \/>\n<code>Select * from sys.remote_data_archive_tables<\/code><\/p>\n<p>To view the batch process of all the data being migrated: (indeed, you can filtrate by the a specific table)<br \/>\n<code>Select * from sys.dm_db_rda_migration_status<\/code><\/p>\n<p>It is also to easily migrate your data back:<br \/>\n<code>ALTER TABLE [Purchasing].[PurchaseOrderDetail]<br \/>\n    SET ( REMOTE_DATA_ARCHIVE ( MIGRATION_STATE = INBOUND ) ) ;<\/code><\/p>\n<p>Moreover, you can select rows to migration by using a filter function. Here is an example:<br \/>\n<code>CREATE FUNCTION dbo.fn_stretchpredicate(@column9 datetime)<br \/>\nRETURNS TABLE<br \/>\nWITH SCHEMABINDING<br \/>\nAS<br \/>\nRETURN  SELECT 1 AS is_eligible<br \/>\n        WHERE @column9 &gt; CONVERT(datetime, '1\/1\/2014', 101)<br \/>\nGO  <\/code><\/p>\n<p>Then when enable the data migration, specify the filter function:<br \/>\n<code>ALTER TABLE [Purchasing].[PurchaseOrderDetail] SET ( REMOTE_DATA_ARCHIVE = ON (<br \/>\n    FILTER_PREDICATE = dbo.fn_stretchpredicate(ModifiedDate),<br \/>\n    MIGRATION_STATE = OUTBOUND<br \/>\n) )<\/code><\/p>\n<p>Of course in Microsoft world, you can also use a wizard to set up this feature. The choice is up to you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, I will present you the new Stretch Database feature in SQL Server 2016. It couples your SQL Server On-Premises database with an Azure SQL Database, allowing to stretch data from one ore more tables to Azure Cloud. This mechanism offers to use low-cost hard drives available in Azure, instead of fast and [&hellip;]<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[229],"tags":[],"type_dbi":[],"class_list":["post-9100","post","type-post","status-publish","format-standard","hentry","category-database-administration-monitoring"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Configure easily your Stretch Database - dbi Blog<\/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.dbi-services.com\/blog\/configure-easily-your-stretch-database\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Configure easily your Stretch Database\" \/>\n<meta property=\"og:description\" content=\"In this blog, I will present you the new Stretch Database feature in SQL Server 2016. It couples your SQL Server On-Premises database with an Azure SQL Database, allowing to stretch data from one ore more tables to Azure Cloud. This mechanism offers to use low-cost hard drives available in Azure, instead of fast and [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/configure-easily-your-stretch-database\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2016-10-21T13:07:43+00:00\" \/>\n<meta name=\"author\" content=\"Nathan Courtine\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nathan Courtine\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configure-easily-your-stretch-database\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configure-easily-your-stretch-database\\\/\"},\"author\":{\"name\":\"Nathan Courtine\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/38305b5ebdcdb4fb784fa31d760862d1\"},\"headline\":\"Configure easily your Stretch Database\",\"datePublished\":\"2016-10-21T13:07:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configure-easily-your-stretch-database\\\/\"},\"wordCount\":311,\"commentCount\":0,\"articleSection\":[\"Database Administration &amp; Monitoring\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configure-easily-your-stretch-database\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configure-easily-your-stretch-database\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configure-easily-your-stretch-database\\\/\",\"name\":\"Configure easily your Stretch Database - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"datePublished\":\"2016-10-21T13:07:43+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/38305b5ebdcdb4fb784fa31d760862d1\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configure-easily-your-stretch-database\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configure-easily-your-stretch-database\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configure-easily-your-stretch-database\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Configure easily your Stretch Database\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/38305b5ebdcdb4fb784fa31d760862d1\",\"name\":\"Nathan Courtine\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0fcc6c91bbc35c976c9d470585e48ae5d500680f1f55de5bbc5f8373b8ebb02c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0fcc6c91bbc35c976c9d470585e48ae5d500680f1f55de5bbc5f8373b8ebb02c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0fcc6c91bbc35c976c9d470585e48ae5d500680f1f55de5bbc5f8373b8ebb02c?s=96&d=mm&r=g\",\"caption\":\"Nathan Courtine\"},\"description\":\"Nathan Courtine has more than four years of experience in Microsoft solutions. He is specialized in SQL Server installation, migration, performance analysis, best practices, etc. Moreover, he has a background in Oracle Java and .NET software and web development. Nathan Courtine is Microsoft Certified in Administering SQL Server 2012 Databases. Nathan Courtine holds an Engineer\u2019s Degree in Computer Science from the ENSISA (Ecole Nationale Sup\u00e9rieure d'Ing\u00e9nieurs Sud Alsace) in Mulhouse (F). His branch-related experience covers Public Sector, Automotive, IT, Financial Services \\\/ Banking, etc.\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/nathan-courtine\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Configure easily your Stretch Database - dbi Blog","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.dbi-services.com\/blog\/configure-easily-your-stretch-database\/","og_locale":"en_US","og_type":"article","og_title":"Configure easily your Stretch Database","og_description":"In this blog, I will present you the new Stretch Database feature in SQL Server 2016. It couples your SQL Server On-Premises database with an Azure SQL Database, allowing to stretch data from one ore more tables to Azure Cloud. This mechanism offers to use low-cost hard drives available in Azure, instead of fast and [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/configure-easily-your-stretch-database\/","og_site_name":"dbi Blog","article_published_time":"2016-10-21T13:07:43+00:00","author":"Nathan Courtine","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Nathan Courtine","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/configure-easily-your-stretch-database\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/configure-easily-your-stretch-database\/"},"author":{"name":"Nathan Courtine","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/38305b5ebdcdb4fb784fa31d760862d1"},"headline":"Configure easily your Stretch Database","datePublished":"2016-10-21T13:07:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/configure-easily-your-stretch-database\/"},"wordCount":311,"commentCount":0,"articleSection":["Database Administration &amp; Monitoring"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/configure-easily-your-stretch-database\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/configure-easily-your-stretch-database\/","url":"https:\/\/www.dbi-services.com\/blog\/configure-easily-your-stretch-database\/","name":"Configure easily your Stretch Database - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2016-10-21T13:07:43+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/38305b5ebdcdb4fb784fa31d760862d1"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/configure-easily-your-stretch-database\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/configure-easily-your-stretch-database\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/configure-easily-your-stretch-database\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Configure easily your Stretch Database"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/38305b5ebdcdb4fb784fa31d760862d1","name":"Nathan Courtine","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0fcc6c91bbc35c976c9d470585e48ae5d500680f1f55de5bbc5f8373b8ebb02c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0fcc6c91bbc35c976c9d470585e48ae5d500680f1f55de5bbc5f8373b8ebb02c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0fcc6c91bbc35c976c9d470585e48ae5d500680f1f55de5bbc5f8373b8ebb02c?s=96&d=mm&r=g","caption":"Nathan Courtine"},"description":"Nathan Courtine has more than four years of experience in Microsoft solutions. He is specialized in SQL Server installation, migration, performance analysis, best practices, etc. Moreover, he has a background in Oracle Java and .NET software and web development. Nathan Courtine is Microsoft Certified in Administering SQL Server 2012 Databases. Nathan Courtine holds an Engineer\u2019s Degree in Computer Science from the ENSISA (Ecole Nationale Sup\u00e9rieure d'Ing\u00e9nieurs Sud Alsace) in Mulhouse (F). His branch-related experience covers Public Sector, Automotive, IT, Financial Services \/ Banking, etc.","url":"https:\/\/www.dbi-services.com\/blog\/author\/nathan-courtine\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/9100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=9100"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/9100\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=9100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=9100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=9100"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=9100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}