ALTER DATABASE Sales SET COMPATIBILITY_LEVEL = 100;

Hi experts

I could describe any scenario where you use this code:
ALTER DATABASE Sales SET COMPATIBILITY_LEVEL = 100;
enrique_aeoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PadawanDBAOperational DBACommented:
what exactly are you asking?
enrique_aeoAuthor Commented:
when I use this command? what is it good for? can share some real scenario?
SET COMPATIBILITY_LEVEL
HuaMin ChenProblem resolverCommented:
Hi,
It is to downgrade the compatibility level of current Sql database to

SQL Server 2008 and SQL Server 2008 R2
Determine the Perfect Price for Your IT Services

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

Vitor MontalvãoMSSQL Senior EngineerCommented:
Each version of SQL Server have an internal level:
SQL Server 7.0 - 70
SQL Server 2000 - 80
SQL Server 2005 - 90
SQL Server 2008/2008R2 - 100
SQL Server 2012 - 110
SQL Server 2014 - 120

So, when you upgrade a database you need to run that command to allow the database to behave as the version you're setting.
For example if you migrated Saled from SQL Server 2005 to 2008 then you'll need to run the command you posted:
ALTER DATABASE Sales SET COMPATIBILITY_LEVEL = 100;
Otherwise the database will behave as a SQL Server 2005 even it's stored in a SQL Server 2008 instance.
PadawanDBAOperational DBACommented:
Vitor is spot on!  One addition that I would like to make is that: up until SQL Server 2014, the compatibility level essentially enforced syntactical changes , not database engine behavior. SQL 2014 introduced changes to the cardinality estimator, which absolutely has an impact on execution plan selection.  That *is* controlled by the compatibility level and also represents the only instance where changing the compatibility level changes database engine behavior, specifically the optimizer.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
enrique_aeoAuthor Commented:
can a T-SQL statement does not work if I do change compatibility
enrique_aeoAuthor Commented:
please
an example: SQL 2014 introduced changes to the cardinality estimator
PadawanDBAOperational DBACommented:
if you are using syntax that no longer works in the new compatibility level, then it will indeed stop working.

on the cardinality estimator: http://blogs.msdn.com/b/psssql/archive/2014/04/01/sql-server-2014-s-new-cardinality-estimator-part-1.aspx
enrique_aeoAuthor Commented:
Agreed.
Do you have any example where T-sql where some have stopped working to change the compatibility level?
PadawanDBAOperational DBACommented:
https://msdn.microsoft.com/en-us/library/bb510680.aspx - has information around the syntax changes with examples, just go through all the versions between what database version it was vs. the version of where you're going.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.