{"id":1093,"date":"2008-01-29T23:51:14","date_gmt":"2008-01-29T23:51:14","guid":{"rendered":"\/blogs\/paul\/post\/Search-Engine-QA-13-Difference-between-database-version-and-database-compatibility-level.aspx"},"modified":"2008-01-29T23:51:14","modified_gmt":"2008-01-29T23:51:14","slug":"search-engine-qa-13-difference-between-database-version-and-database-compatibility-level","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-13-difference-between-database-version-and-database-compatibility-level\/","title":{"rendered":"Search Engine Q&#038;A #13: Difference between database version and database compatibility level"},"content":{"rendered":"<p><FONT face=Verdana size=2><br \/>\n<P>This has been causing some problems on the various groups and forums over the last few days so I thought I&#8217;d repost this from my old Storage Engine blog. The questions have been around attaching 2005 databases to 2000 servers &#8211; even databases that are in 80 compat mode &#8211; and it doesn&#8217;t work. Why?<\/P><br \/>\n<P minmax_bound=\"true\">The&nbsp;confusion is between database compatibility level and database<EM minmax_bound=\"true\"> version<\/EM>. Here&#8217;s a quick explanation of the difference.<\/P><br \/>\n<P minmax_bound=\"true\"><STRONG minmax_bound=\"true\">Database version<\/STRONG><\/P><br \/>\n<P minmax_bound=\"true\">The database version is a number stamped in the boot page of a database that indicates the SQL Server version of the most recent SQL Server instance the database was attached to. The database version number does not equal the SQL Server version. For example,&nbsp;doing the following:<\/P><FONT color=#0000ff size=2 minmax_bound=\"true\"><br \/>\n<BLOCKQUOTE dir=ltr style=\"MARGIN-RIGHT: 0px\"><br \/>\n<P minmax_bound=\"true\"><FONT face=\"Courier New\">SELECT<\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#000000 size=2 minmax_bound=\"true\"> <\/FONT><FONT color=#ff00ff size=2 minmax_bound=\"true\">@@version<\/FONT><FONT color=#808080 size=2 minmax_bound=\"true\">;<BR><\/FONT><\/FONT><FONT size=2 minmax_bound=\"true\"><FONT face=\"Courier New\">GO<\/FONT><\/P><\/BLOCKQUOTE><\/FONT><br \/>\n<P minmax_bound=\"true\">on one SQL Server instance on my laptop returns:<\/P><br \/>\n<P minmax_bound=\"true\">Microsoft SQL Server 2005 &#8211; 9.00.3054.00 (Intel X86)&nbsp;&nbsp; Feb 13 2007 23:02:48&nbsp;&nbsp; Copyright (c) 1988-2005 Microsoft Corporation&nbsp; Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 2) <\/P><br \/>\n<P minmax_bound=\"true\">However, the database version is 611. You can see the database version but if you attach a database from an earlier version of SQL Server, you&#8217;ll see these numbers in the error log as SQL Server reports what upgrade steps its doing. You can also see by doing the following:<\/P><FONT color=#0000ff size=2 minmax_bound=\"true\"><br \/>\n<BLOCKQUOTE dir=ltr style=\"MARGIN-RIGHT: 0px\"><br \/>\n<P minmax_bound=\"true\"><FONT face=\"Courier New\">USE<\/FONT><\/FONT><FONT face=\"Courier New\" color=#000000 size=2 minmax_bound=\"true\"> master<\/FONT><FONT face=\"Courier New\"><FONT color=#808080 size=2 minmax_bound=\"true\">;<BR><\/FONT><FONT size=2 minmax_bound=\"true\">GO<\/P><\/FONT><\/FONT><FONT color=#0000ff size=2 minmax_bound=\"true\"><br \/>\n<P minmax_bound=\"true\"><FONT face=\"Courier New\">SELECT<\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#000000 size=2 minmax_bound=\"true\"> <\/FONT><FONT color=#ff00ff size=2 minmax_bound=\"true\">DatabaseProperty <\/FONT><FONT color=#808080 size=2 minmax_bound=\"true\">(<\/FONT><FONT color=#ff0000 size=2 minmax_bound=\"true\">&#8216;dbccpagetest&#8217;<\/FONT><FONT color=#808080 size=2 minmax_bound=\"true\">,<\/FONT><FONT color=#000000 size=2 minmax_bound=\"true\"> <\/FONT><FONT color=#ff0000 size=2 minmax_bound=\"true\">&#8216;version&#8217;<\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#808080 size=2 minmax_bound=\"true\">);<BR><\/FONT><FONT size=2 minmax_bound=\"true\">GO<\/P><\/BLOCKQUOTE><\/FONT><\/FONT><br \/>\n<P minmax_bound=\"true\">Some things to note about database version:<\/P><br \/>\n<UL minmax_bound=\"true\"><br \/>\n<LI minmax_bound=\"true\">SQL Server is not up-level compatible. You cannot attach a database that was created on (or has been upgraded to) SQL Server 2005 to any earlier version of SQL Server (also true for trying to attach a 2000 database to 7.0, and so on).<br \/>\n<LI minmax_bound=\"true\">You cannot attach a database that was created on an earlier version without going through the proper upgrade procedures. Forcibly attaching a database using various hacky methods will result in all kinds of weird errors, and possibly crashes.<\/LI><\/UL><br \/>\n<P minmax_bound=\"true\"><STRONG minmax_bound=\"true\">Database compatibility level<\/STRONG><\/P><br \/>\n<P minmax_bound=\"true\" mce_keep=\"true\">The database compatibility level determines how certain database behaviors work. For instance, in 90 compatibility, you need to use the OUTER JOIN syntax to do an outer join, whereas in earlier compatibility levels, you can use &#8216;*=&#8217; and &#8216;=*&#8217;. Contrary to popular myth, all of the behavioral differences ARE documented &#8211; in the Books Online section for <STRONG minmax_bound=\"true\">sp_dbcmptlevel<\/STRONG> &#8211; the SP used to set the compatibility level.<\/P><br \/>\n<P minmax_bound=\"true\" mce_keep=\"true\">There are 5 supported compatibility levels support by SQL Server 2005:<\/P><br \/>\n<BLOCKQUOTE minmax_bound=\"true\"><br \/>\n<P minmax_bound=\"true\"><B minmax_bound=\"true\">60<\/B> = SQL Server 6.0 <\/P><br \/>\n<P minmax_bound=\"true\"><B minmax_bound=\"true\">65<\/B> = SQL Server 6.5 <\/P><br \/>\n<P minmax_bound=\"true\"><B minmax_bound=\"true\">70<\/B> = SQL Server 7.0 <\/P><br \/>\n<P minmax_bound=\"true\"><B minmax_bound=\"true\">80<\/B> = SQL Server 2000 <\/P><br \/>\n<P minmax_bound=\"true\"><B minmax_bound=\"true\">90<\/B> = SQL Server 2005 <\/P><\/BLOCKQUOTE><br \/>\n<P minmax_bound=\"true\">You can see the compatibility level of all databases by doing:<\/P><FONT color=#0000ff size=2 minmax_bound=\"true\"><br \/>\n<BLOCKQUOTE dir=ltr style=\"MARGIN-RIGHT: 0px\"><br \/>\n<P minmax_bound=\"true\"><FONT face=\"Courier New\">SELECT<\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#000000 size=2 minmax_bound=\"true\"> <\/FONT><FONT color=#0000ff size=2 minmax_bound=\"true\">name<\/FONT><FONT color=#000000 size=2 minmax_bound=\"true\"> <\/FONT><FONT color=#0000ff size=2 minmax_bound=\"true\">AS<\/FONT><FONT color=#000000 size=2 minmax_bound=\"true\"> <\/FONT><FONT color=#ff0000 size=2 minmax_bound=\"true\">&#8216;DB Name&#8217;<\/FONT><FONT color=#808080 size=2 minmax_bound=\"true\">, <\/FONT><\/FONT><FONT size=2 minmax_bound=\"true\"><FONT face=\"Courier New\">compatibility_level <\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#0000ff size=2 minmax_bound=\"true\">AS<\/FONT><FONT size=2 minmax_bound=\"true\"> <\/FONT><FONT color=#ff0000 size=2 minmax_bound=\"true\">&#8216;Compatibility Level&#8217;<BR><\/FONT><\/FONT><FONT color=#0000ff size=2 minmax_bound=\"true\"><FONT face=\"Courier New\">FROM<\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#000000 size=2 minmax_bound=\"true\"> master<\/FONT><FONT color=#808080 size=2 minmax_bound=\"true\">.<\/FONT><FONT color=#008000 size=2 minmax_bound=\"true\">sys.databases<\/FONT><FONT color=#808080 size=2 minmax_bound=\"true\">;<BR><\/FONT><\/FONT><FONT face=\"Courier New\">GO<\/FONT><\/P><\/BLOCKQUOTE><br \/>\n<P minmax_bound=\"true\">Some things to note about compatibility levels:<\/P><br \/>\n<UL minmax_bound=\"true\"><br \/>\n<LI minmax_bound=\"true\">A database created on SQL Server 2005 will have a default compatibility level of 90, unless the <EM minmax_bound=\"true\">model<\/EM> database has a different compatibility level, in which case the new database inherits the compatibility level of <EM minmax_bound=\"true\">model<\/EM>.<br \/>\n<LI minmax_bound=\"true\">New features may work under older compatibility levels but beware of SET options.<br \/>\n<LI minmax_bound=\"true\">An upgraded database retains its compatibility level. For example, a database that was created on SQL Server 2000, and didn&#8217;t have its compatibility level altered, will stay in 80 compatibility level when its upgraded to SQL Server 2005.<\/LI><\/UL><br \/>\n<P minmax_bound=\"true\"><STRONG minmax_bound=\"true\">Summary<\/STRONG><\/P><br \/>\n<P minmax_bound=\"true\">This was just a quick &#8211; and by no means comprehensive &#8211; explanation of the difference between the two terms. Basically, there&#8217;s no relationship between them.<\/P><\/FONT><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This has been causing some problems on the various groups and forums over the last few days so I thought I&#8217;d repost this from my old Storage Engine blog. The questions have been around attaching 2005 databases to 2000 servers &#8211; even databases that are in 80 compat mode &#8211; and it doesn&#8217;t work. Why? [&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-1093","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 #13: Difference between database version and database compatibility level - 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-13-difference-between-database-version-and-database-compatibility-level\/\" \/>\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 #13: Difference between database version and database compatibility level - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"This has been causing some problems on the various groups and forums over the last few days so I thought I&#8217;d repost this from my old Storage Engine blog. The questions have been around attaching 2005 databases to 2000 servers &#8211; even databases that are in 80 compat mode &#8211; and it doesn&#8217;t work. Why? [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-13-difference-between-database-version-and-database-compatibility-level\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2008-01-29T23:51:14+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=\"3 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\/search-engine-qa-13-difference-between-database-version-and-database-compatibility-level\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-13-difference-between-database-version-and-database-compatibility-level\/\",\"name\":\"Search Engine Q&A #13: Difference between database version and database compatibility level - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2008-01-29T23:51:14+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-13-difference-between-database-version-and-database-compatibility-level\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-13-difference-between-database-version-and-database-compatibility-level\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-13-difference-between-database-version-and-database-compatibility-level\/#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 #13: Difference between database version and database compatibility level\"}]},{\"@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 #13: Difference between database version and database compatibility level - 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-13-difference-between-database-version-and-database-compatibility-level\/","og_locale":"en_US","og_type":"article","og_title":"Search Engine Q&A #13: Difference between database version and database compatibility level - Paul S. Randal","og_description":"This has been causing some problems on the various groups and forums over the last few days so I thought I&#8217;d repost this from my old Storage Engine blog. The questions have been around attaching 2005 databases to 2000 servers &#8211; even databases that are in 80 compat mode &#8211; and it doesn&#8217;t work. Why? [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-13-difference-between-database-version-and-database-compatibility-level\/","og_site_name":"Paul S. Randal","article_published_time":"2008-01-29T23:51:14+00:00","author":"Paul Randal","twitter_misc":{"Written by":"Paul Randal","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-13-difference-between-database-version-and-database-compatibility-level\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-13-difference-between-database-version-and-database-compatibility-level\/","name":"Search Engine Q&A #13: Difference between database version and database compatibility level - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2008-01-29T23:51:14+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-13-difference-between-database-version-and-database-compatibility-level\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-13-difference-between-database-version-and-database-compatibility-level\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-13-difference-between-database-version-and-database-compatibility-level\/#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 #13: Difference between database version and database compatibility level"}]},{"@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\/1093","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=1093"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/1093\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=1093"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=1093"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=1093"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}