Cannot set SQL 2005 database to compatability level 80

Neil Thompson
Neil Thompson used Ask the Experts™
on
Hi

Hoping someone can help. Due to old compiled code I am not able to amend a SQL query that wont run on SQL 2005+ (its currently working fine on SQL 2000 but the server and SQL needs to go :) )

I need to get compatibility mode to 80;

I've tried the following which returns an error saying the levels are only 90 upwards, any ideas please?

Neil

I've tried:
ALTER DATABASE corporate
SET COMPATABILITY_LEVEL = 80
GO

Open in new window


message returned:
Msg 15048, Level 16, State 1, Line 3
Valid values of the database compatability level are 90, 100 or 110

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Steve WalesSenior Database Administrator

Commented:
Since the error message is telling you you can go up to 110, that tells me you're running SQL 2012.

You can't set compatibility level to 80 in SQL 2012, it's just not supported.

See the matrix of what is supported here: https://msdn.microsoft.com/en-us/library/bb510680.aspx

Time to rewrite that code.
Vikas GargAssociate Principal Engineer
Top Expert 2014
Commented:
Hello,

The best practice to change the compatibility level of database is in following three steps.

    Set the database to single user access mode by using
    ALTER DATABASE SET SINGLE_USER
    Change the compatibility level of the database.
    Put the database in multiuser access mode by using
    ALTER DATABASE SET MULTI_USER


Please note - A database containing an indexed view cannot be changed to a compatibility level lower than 80.

----SQL Server 2005 database compatible level to SQL Server 2000
EXEC sp_dbcmptlevel AdventureWorks, 80;
GO
Neil ThompsonSenior Systems Developer

Author

Commented:
Thanks Guys,

Database is definitely 2005
SQL About
I've tried Vikas's code but still get this:
Error
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Senior Database Administrator
Commented:
What that is showing is that your TOOLS are 2005.  Doesn't necessarily mean that the database is.   I just tried that internally.  Connected to a 2008R2 DB using tools for SQL 2005.   Help/About showed 2005, but this query below returned 10.50.2550 - showing that I used 2005 SSMS to connect to 2008 R2 database.

Execute this query:  select @@VERSION;

What do you get back ?
Neil ThompsonSenior Systems Developer

Author

Commented:
Thanks Steve,  2012 :(

User error, we were connecting via the 2005 server to a 2012 version, rather than the same server's 2005 copy

Stupid mistake, caught by your question.

Thanks
Neil
Neil ThompsonSenior Systems Developer

Author

Commented:
Great comments, thanks for the "how to", and the "why it wasn't working" ideas
Neil

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial