title | description | author | ms.author | ms.date | ms.service | ms.subservice | ms.topic | ms.custom | f1_keywords | helpviewer_keywords | dev_langs | monikerRange | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
MinDbCompatibilityLevel (geography Data Type) |
MinDbCompatibilityLevel (geography Data Type) |
MladjoA |
mlandzic |
03/14/2017 |
sql |
t-sql |
reference |
|
|
|
|
=azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric |
[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance FabricSQLDB]
Returns the minimum database compatibility that recognizes the geography data type.
. MinDbCompatibilityLevel ( )
[!INCLUDEssNoVersion] return type: int
CLR return type: int
Use MinDbCompatibilityLevel()
to test a spatial object for compatibility before changing the compatibility level on a database. An invalid geography type returns 110.
The following example tests a CircularString
instance for compatibility with an earlier version of [!INCLUDEssNoVersion]:
DECLARE @g geometry = 'CIRCULARSTRING(-120.533 46.566, -118.283 46.1, -122.3 47.45)';
IF @g.MinDbCompatibilityLevel() <= 110
BEGIN
SELECT @g.ToString();
END
The following example tests a LineString
instance for compatibility with [!INCLUDEsql2008-md]:
DECLARE @g geometry = 'LINESTRING(-120.533 46.566, -118.283 46.1, -122.3 47.45)';
IF @g.MinDbCompatibilityLevel() <= 100
BEGIN
SELECT @g.ToString();
END
The following example shows the compatibility levels for two geography
instances. One is smaller than a hemisphere and the other is larger than a hemisphere:
DECLARE @g geography = geography::Parse('POLYGON((0 -10, 120 -10, 240 -10, 0 -10))');
DECLARE @h geography = geography::Parse('POLYGON((0 10, 120 10, 240 10, 0 10))');
IF (@g.EnvelopeAngle() >= 90)
BEGIN
SELECT @g.MinDbCompatibilityLevel();
END
IF (@h.EnvelopeAngle() < 90)
BEGIN
SELECT @h.MinDbCompatibilityLevel();
END
The first SELECT statement returns 110 and the second SELECT statement returns 100.
ALTER DATABASE Compatibility Level (Transact-SQL)
SQL Server Database Engine Backward Compatibility