From df60c87eef69878e8fb4e403726bb4f75a5eba4f Mon Sep 17 00:00:00 2001 From: Kevin Locke Date: Fri, 31 Dec 2021 17:22:08 -0700 Subject: [PATCH] Document date/time addition change at compatibility level 110 At compatibility level 100 and below, the addition operator accepts an operand of type `DATE`, `TIME`, `DATETIME2`, or `DATETIMEOFFSET` if the other operand has type `DATETIME` or `SMALLDATETIME`. At compatibility level 110 and higher, an operand of type `DATE`, `TIME`, `DATETIME2`, or `DATETIMEOFFSET` causes an error. For example: ```sql SELECT CAST('2021-12-31T00:00:00' AS DATETIME) + CAST('17:00:00' AS TIME); ``` At compatibilty level 100: > 2021-12-31 17:00:00.000 At compatibility level 110: > Msg 402, Level 16, State 1, Line 1 > The data types datetime and time are incompatible in the add operator. Add this to the "Differences between Lower Compatibility Levels and Levels 100 and 110" in the [ALTER DATABASE Compatibility Level (Transact-SQL)] page. [ALTER DATABASE Compatibility Level (Transact-SQL)]: https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-transact-sql-compatibility-level Signed-off-by: Kevin Locke --- .../alter-database-transact-sql-compatibility-level.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/t-sql/statements/alter-database-transact-sql-compatibility-level.md b/docs/t-sql/statements/alter-database-transact-sql-compatibility-level.md index 12d0bafeb5f..b7de6561e6a 100644 --- a/docs/t-sql/statements/alter-database-transact-sql-compatibility-level.md +++ b/docs/t-sql/statements/alter-database-transact-sql-compatibility-level.md @@ -281,6 +281,7 @@ This section describes new behaviors introduced with compatibility level 110. Th |`PIVOT` is allowed in a recursive common table expression (CTE) query. However, the query returns incorrect results when there are multiple rows per grouping.|`PIVOT` is not allowed in a recursive common table expression (CTE) query. An error is returned.| |The RC4 algorithm is only supported for backward compatibility. New material can only be encrypted using RC4 or RC4_128 when the database is in compatibility level 90 or 100. (Not recommended.) In [!INCLUDE[ssSQL11](../../includes/sssql11-md.md)], material encrypted using RC4 or RC4_128 can be decrypted in any compatibility level.|New material cannot be encrypted using RC4 or RC4_128. Use a newer algorithm such as one of the AES algorithms instead. In [!INCLUDE[ssSQL11](../../includes/sssql11-md.md)], material encrypted using RC4 or RC4_128 can be decrypted in any compatibility level.| |The default style for `CAST` and `CONVERT` operations on **time** and **datetime2** data types is 121 except when either type is used in a computed column expression. For computed columns, the default style is 0. This behavior impacts computed columns when they are created, used in queries involving auto-parameterization, or used in constraint definitions.

Example D in the Examples section below shows the difference between styles 0 and 121. It does not demonstrate the behavior described above. For more information about date and time styles, see [CAST and CONVERT](../../t-sql/functions/cast-and-convert-transact-sql.md).|Under compatibility level 110, the default style for `CAST` and `CONVERT` operations on **time** and **datetime2** data types is always 121. If your query relies on the old behavior, use a compatibility level less than 110, or explicitly specify the 0 style in the affected query.

Upgrading the database to compatibility level 110 will not change user data that has been stored to disk. You must manually correct this data as appropriate. For example, if you used `SELECT INTO` to create a table from a source that contained a computed column expression described above, the data (using style 0) would be stored rather than the computed column definition itself. You would need to manually update this data to match style 121.| +|The [+ (Addition)](../../t-sql/language-elements/add-transact-sql.md) operator may be applied to a operand of type **date**, **time**, **datetime2**, or **datetimeoffset** if the other operand has type **datetime** or **smalldatetime**.|Attempting to apply the addition operator to an operand of type **date**, **time**, **datetime2**, or **datetimeoffset** and an operand of type **datetime** or **smalldatetime** will cause error 402.| |Any columns in remote tables of type **smalldatetime** that are referenced in a partitioned view are mapped as **datetime**. Corresponding columns in local tables (in the same ordinal position in the select list) must be of type **datetime**.|Any columns in remote tables of type **smalldatetime** that are referenced in a partitioned view are mapped as **smalldatetime**. Corresponding columns in local tables (in the same ordinal position in the select list) must be of type **smalldatetime**.

After upgrading to 110, the distributed partitioned view will fail because of the data type mismatch. You can resolve this by changing the data type on the remote table to **datetime** or setting the compatibility level of the local database to 100 or lower.| |`SOUNDEX` function implements the following rules:

1) Upper-case H or upper-case W are ignored when separating two consonants that have the same number in the `SOUNDEX` code.

2) If the first 2 characters of *character_expression* have the same number in the `SOUNDEX` code, both characters are included. Else, if a set of side-by-side consonants have the same number in the `SOUNDEX` code, all of them are excluded except the first.|`SOUNDEX` function implements the following rules:

1) If upper-case H or upper-case W separate two consonants that have the same number in the `SOUNDEX` code, the consonant to the right is ignored

2) If a set of side-by-side consonants have the same number in the `SOUNDEX` code, all of them are excluded except the first.



The additional rules may cause the values computed by the `SOUNDEX` function to be different than the values computed under earlier compatibility levels. After upgrading to compatibility level 110, you may need to rebuild the indexes, heaps, or CHECK constraints that use the `SOUNDEX` function. For more information, see [SOUNDEX](../../t-sql/functions/soundex-transact-sql.md).|