Search code examples
sql-server-2008versioncompatibilitysql-server-2012

How to develop for SQL Server 2008 using 2012?


When I use MSBuild 4 I can target .NET Framework 3.5 and older versions, and all features available only on the version 4 will not be available on that project.

I would like to do a similar thing in SQL Server 2012. Can I configure a database in it to behave similary to a SQL Server 2008 one? Can I make one database to not accept commands only available to SQL Server 2012?


Solution

  • You can set the Compatability Level within the database properties.

    1. Right Click the Database
    2. Click Properties
    3. Select Options
    4. Choose the Compatability Level

      • 110 = SQL 2012
      • 100 = SQL 2008 & 2008 R2
      • 90 = SQL 2005

    This option only affects the behaviour of this particular database, not the entire server. It should be regarded only as partial backwards compatibility. If your intention is for SQL Server to treat this database as a SQL 2008 database, then the best way to do this would be to run it within SQL 2008 rather than SQL 2012.

    Here is a very detailed explanation: http://technet.microsoft.com/en-us/library/bb510680(v=sql.110).aspx

    T-SQL

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