Sql-server – Compatibility level for SQL Server database

compatibilitysql serversql-server-2005sql-server-2008

My database hoster allows to restore SQL Server databases with a compatibility level of 90 (SQL Server 2005). My database is created locally with a compatibility level of 100 (SQL Server 2008).

So, I generated script of my database (version 2008) and run in SQL Server 2005, backup and restore to my database hoster, it works. Currently I do likes it.

And then I found ALTER DATABASE that can change compatibility level of database likes

ALTER DATABASE database_name 
SET COMPATIBILITY_LEVEL = { 90 | 100 | 110 }

 90 = SQL Server 2005
 100 = SQL Server 2008 and SQL Server 2008 R2
 110 = SQL Server 2012

I turn my database compatibility level using this script in SQL Server 2008, backup my database and restore to my database hoster. But it doesn't work. I want to know why? Is there a better way to fix it ?

Best Answer

You can NEVER restore a database from a newer version of SQL Server (like your 2008 version) onto an older SQL Server (2005) instance.

No matter what you try, no trick, no hack, no workaround - it just cannot be done.

The compatibility level doesn't make any difference either. It just makes your newer database (like on 2008) behave as if it were an older one (like 2005) - so the features you can use are limited to what the older database supported.

But internally - it's still a 2008 database and it cannot be restored to a 2005 instance.