Warning: Constant WP_TEMP_DIR already defined in /var/www/html/blogs/glenn/wp-config.php on line 94

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/blogs/glenn/wp-config.php:94) in /var/www/html/blogs/glenn/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/blogs/glenn/wp-config.php:94) in /var/www/html/blogs/glenn/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/blogs/glenn/wp-config.php:94) in /var/www/html/blogs/glenn/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/blogs/glenn/wp-config.php:94) in /var/www/html/blogs/glenn/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/blogs/glenn/wp-config.php:94) in /var/www/html/blogs/glenn/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/blogs/glenn/wp-config.php:94) in /var/www/html/blogs/glenn/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/blogs/glenn/wp-config.php:94) in /var/www/html/blogs/glenn/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/blogs/glenn/wp-config.php:94) in /var/www/html/blogs/glenn/wp-includes/rest-api/class-wp-rest-server.php on line 1902
{"id":1253,"date":"2017-08-21T13:08:39","date_gmt":"2017-08-21T20:08:39","guid":{"rendered":"http:\/\/3.209.169.194\/blogs\/glenn\/?p=1253"},"modified":"2020-01-11T12:51:54","modified_gmt":"2020-01-11T20:51:54","slug":"upgrading-sql-server-database-compatibility-levels","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/","title":{"rendered":"Upgrading SQL Server– Database Compatibility Levels"},"content":{"rendered":"

One important factor to contemplate during an upgrade and migration effort are your database compatibility levels, which control certain database behaviors to be compatible with a particular version of SQL Server. Unlike the database file version (which get changed when you restore a database backup in a newer version or attach an older database to a newer version of SQL Server), the database compatibility level can be changed back and forth to different values.<\/p>\n

Here is an example of how to set the database compatibility level in T-SQL<\/a>:<\/p>\n

\n

ALTER DATABASE AdventureWorks2014 SET COMPATIBILITY_LEVEL = 120;<\/p>\n<\/blockquote>\n

Figure 1 shows the supported database compatibility levels by major SQL Server version.<\/font><\/p>\n

\"Picture6\"<\/a><\/p>\n

  Figure 1: Supported Database Compatibility Levels By Version<\/strong><\/p>\n

By default, new user databases that are created in an instance of SQL Server are set to the version of the SQL Server instance (so a new user database in SQL Server 2017 would have a database compatibility level of 140). The exception would be if the model database has a lower database compatibility level. Upgrading a database with a database compatibility level lower than the lowest allowed level, sets the database compatibility level to the lowest compatibility level allowed for that version (as shown in Figure 1).<\/p>\n

The classic scenario for why you might want to use an older database compatibility level after an upgrade to a newer version of SQL Server is to use it as an interim migration aid to work around some application compatibility issues that might surface after a migration (which you hopefully discovered during your pre-migration testing efforts). After further testing and possible database\/application changes, it is pretty common to eventually change the database compatibility level to match the database engine version of the instance, which lets you take advantage of some of the new features and behavior differences in that version<\/a>.<\/p>\n

With SQL Server 2014 and newer, the database compatibility level also controls whether the new cardinality estimator or the legacy cardinality estimator is used. The new cardinality estimator gives equivalent or better query performance for many to most queries, but it sometimes has very significant performance regressions. It is very important<\/u><\/strong> to do as much testing as possible before you change the compatibility level to 120 or higher. My post Upgrading SQL Server\u2013Diagnosing Performance Regressions<\/a> goes into much more detail about this issue.<\/p>\n

 <\/p>\n

Additional Resources<\/font><\/u><\/strong> <\/p>\n

My new Pluralsight<\/a> course, SQL Server: Upgrading and Migrating to SQL Server 2016<\/a> has just been published. This is my eleventh course for Pluralsight, but the complete list of my courses is here<\/a>. <\/p>\n

Building on this online course is a new three day class, IEUpgrade: Immersion Event on Upgrading SQL Server<\/a>, taught by myself<\/a> and Tim Radney<\/a>. The first round of this course will be taught in Chicago from October 11-13, 2017. <\/p>\n

Finally, I will be presenting a half-day session called Migrating to SQL Server 2017<\/a> at the PASS Summit 2017<\/a> in Seattle, WA from October 31- November 3, 2017. <\/p>\n

Here is a link to the complete series<\/a> about upgrading SQL Server.<\/p>\n","protected":false},"excerpt":{"rendered":"

One important factor to contemplate during an upgrade and migration effort are your database compatibility levels, which control certain database behaviors to be compatible with a particular version of SQL Server. Unlike the database file version (which get changed when you restore a database backup in a newer version or attach an older database to […]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[246,342,353],"tags":[350,352],"class_list":["post-1253","post","type-post","status-publish","format-standard","hentry","category-sql-server-2016","category-sql-server-2017","category-upgrading-sql-server","tag-upgrading-to-sql-server-2016","tag-upgrading-to-sql-server-2017"],"yoast_head":"\nUpgrading SQL Server– Database Compatibility Levels - Glenn Berry<\/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\/glenn\/upgrading-sql-server-database-compatibility-levels\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Upgrading SQL Server– Database Compatibility Levels - Glenn Berry\" \/>\n<meta property=\"og:description\" content=\"One important factor to contemplate during an upgrade and migration effort are your database compatibility levels, which control certain database behaviors to be compatible with a particular version of SQL Server. Unlike the database file version (which get changed when you restore a database backup in a newer version or attach an older database to […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/\" \/>\n<meta property=\"og:site_name\" content=\"Glenn Berry\" \/>\n<meta property=\"article:published_time\" content=\"2017-08-21T20:08:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-01-11T20:51:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-content\/uploads\/2017\/08\/Picture6_thumb.png\" \/>\n<meta name=\"author\" content=\"Glenn Berry\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Glenn Berry\" \/>\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\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/\",\"name\":\"Upgrading SQL Server– Database Compatibility Levels - Glenn Berry\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-content\/uploads\/2017\/08\/Picture6_thumb.png\",\"datePublished\":\"2017-08-21T20:08:39+00:00\",\"dateModified\":\"2020-01-11T20:51:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/#\/schema\/person\/57a8972435106bac7970692fcf5edfa7\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/#primaryimage\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-content\/uploads\/2017\/08\/Picture6_thumb.png\",\"contentUrl\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-content\/uploads\/2017\/08\/Picture6_thumb.png\",\"width\":1028,\"height\":421},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Upgrading SQL Server– Database Compatibility Levels\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/\",\"name\":\"Glenn Berry\",\"description\":\"Semi-random musings about SQL Server performance\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/?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\/glenn\/#\/schema\/person\/57a8972435106bac7970692fcf5edfa7\",\"name\":\"Glenn Berry\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/64bdac8830f25f2f8cc780f8a1286c66ff1182218009271e7a953639596f7e25?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/64bdac8830f25f2f8cc780f8a1286c66ff1182218009271e7a953639596f7e25?s=96&d=mm&r=g\",\"caption\":\"Glenn Berry\"},\"sameAs\":[\"https:\/\/www.sqlskills.com\/blogs\/glenn\/\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/glenn\/author\/glenn\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Upgrading SQL Server– Database Compatibility Levels - Glenn Berry","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\/glenn\/upgrading-sql-server-database-compatibility-levels\/","og_locale":"en_US","og_type":"article","og_title":"Upgrading SQL Server– Database Compatibility Levels - Glenn Berry","og_description":"One important factor to contemplate during an upgrade and migration effort are your database compatibility levels, which control certain database behaviors to be compatible with a particular version of SQL Server. Unlike the database file version (which get changed when you restore a database backup in a newer version or attach an older database to […]","og_url":"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/","og_site_name":"Glenn Berry","article_published_time":"2017-08-21T20:08:39+00:00","article_modified_time":"2020-01-11T20:51:54+00:00","og_image":[{"url":"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-content\/uploads\/2017\/08\/Picture6_thumb.png","type":"","width":"","height":""}],"author":"Glenn Berry","twitter_misc":{"Written by":"Glenn Berry","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/","url":"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/","name":"Upgrading SQL Server– Database Compatibility Levels - Glenn Berry","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/glenn\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/#primaryimage"},"image":{"@id":"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-content\/uploads\/2017\/08\/Picture6_thumb.png","datePublished":"2017-08-21T20:08:39+00:00","dateModified":"2020-01-11T20:51:54+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/glenn\/#\/schema\/person\/57a8972435106bac7970692fcf5edfa7"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/#primaryimage","url":"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-content\/uploads\/2017\/08\/Picture6_thumb.png","contentUrl":"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-content\/uploads\/2017\/08\/Picture6_thumb.png","width":1028,"height":421},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/glenn\/upgrading-sql-server-database-compatibility-levels\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/glenn\/"},{"@type":"ListItem","position":2,"name":"Upgrading SQL Server– Database Compatibility Levels"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/glenn\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/glenn\/","name":"Glenn Berry","description":"Semi-random musings about SQL Server performance","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/glenn\/?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\/glenn\/#\/schema\/person\/57a8972435106bac7970692fcf5edfa7","name":"Glenn Berry","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/glenn\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/64bdac8830f25f2f8cc780f8a1286c66ff1182218009271e7a953639596f7e25?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/64bdac8830f25f2f8cc780f8a1286c66ff1182218009271e7a953639596f7e25?s=96&d=mm&r=g","caption":"Glenn Berry"},"sameAs":["https:\/\/www.sqlskills.com\/blogs\/glenn\/"],"url":"https:\/\/www.sqlskills.com\/blogs\/glenn\/author\/glenn\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-json\/wp\/v2\/posts\/1253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-json\/wp\/v2\/comments?post=1253"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-json\/wp\/v2\/posts\/1253\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-json\/wp\/v2\/media?parent=1253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-json\/wp\/v2\/categories?post=1253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/glenn\/wp-json\/wp\/v2\/tags?post=1253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}