Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
696 views
in Technique[技术] by (71.8m points)

database - Understanding COMPATIBILITY_LEVEL in SQL Server

I understood that setting a database to a COMPATIBILITY_LEVEL prior to your native one prevented features from being used. However this doesn't seem to be the case. Witness the following SQL script:

CREATE DATABASE Foo
GO
USE Foo
GO
ALTER DATABASE Foo SET COMPATIBILITY_LEVEL = 80
GO

CREATE TABLE Bar
(
    Id UNIQUEIDENTIFIER NOT NULL,
    TestNvcMax NVARCHAR (MAX) NOT NULL, -- Arrived in SQL 2005
    TestDateTime2 DATETIME2 (7) NOT NULL -- Arrived in SQL 2008
)
GO

But this table creates perfectly - any ideas? I would have thought some kind of an error message or warning would have been appropriate

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here you can read about the differences between compatibility level 80, 90 and 100. ALTER DATABASE Compatibility Level

Apparently new data types is not affected. I think that compatibility level is there to make SQL Server "behave" like the older version, not prevent you from doing new fancy stuff.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...