Skip to content

Commit 683008c

Browse files
authored
Merge pull request #7811 from pmasl/patch-326
Update collations.md
2 parents aa79a1b + 5871c82 commit 683008c

1 file changed

Lines changed: 16 additions & 18 deletions

File tree

docs/t-sql/statements/collations.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Collations | Microsoft Docs"
2+
title: "COLLATE (Transact-SQL) | Microsoft Docs"
33
ms.custom: ""
44
ms.date: "09/07/2018"
55
ms.prod: sql
@@ -21,10 +21,10 @@ ms.author: carlrab
2121
manager: craigg
2222
monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||=sqlallproducts-allversions||>=sql-server-linux-2017||=azuresqldb-mi-current"
2323
---
24-
# Collations
24+
# COLLATE (Transact-SQL)
2525
[!INCLUDE[tsql-appliesto-ss2008-all-md](../../includes/tsql-appliesto-ss2008-all-md.md)]
2626

27-
Is a clause that can be applied to a database definition or a column definition to define the collation, or to a character string expression to apply a collation cast.
27+
Defines a collation of a database or table column, or a collation cast operation when applied to character string expression. Collation name can be either a Windows collation name or a SQL collation name. If not specified during database creation, the database is assigned the default collation of the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. If not specified during table column creation, the column is assigned the default collation of the database.
2828

2929
![Topic link icon](../../database-engine/configure-windows/media/topic-link.gif "Topic link icon") [Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
3030

@@ -44,49 +44,47 @@ COLLATE { <collation_name> | database_default }
4444

4545
*SQL_collation_name* is the collation name for a [SQL Server Collation Name](../../t-sql/statements/sql-server-collation-name-transact-sql.md).
4646

47-
When applying a collation at the database definition level, Unicode-only Windows collations cannot be used with the COLLATE clause.
48-
4947
**database_default**
5048
Causes the COLLATE clause to inherit the collation of the current database.
5149

5250
## Remarks
53-
The COLLATE clause can be specified at several levels. These include the following:
51+
The COLLATE clause can be specified at several levels. These include the following:
5452

5553
1. Creating or altering a database.
5654

57-
You can use the COLLATE clause of the CREATE DATABASE or ALTER DATABASE statement to specify the default collation of the database. You can also specify a collation when you create a database using [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)]. If you do not specify a collation, the database is assigned the default collation of the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)].
55+
You can use the COLLATE clause of the `CREATE DATABASE` or `ALTER DATABASE` statement to specify the default collation of the database. You can also specify a collation when you create a database using [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)]. If you do not specify a collation, the database is assigned the default collation of the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)].
5856

5957
> [!NOTE]
60-
> Windows Unicode-only collations can only be used with the COLLATE clause to apply collations to the **nchar**, **nvarchar**, and **ntext** data types on column-level and expression-level data; they cannot be used with the COLLATE clause to change the collation of a database or server instance.
58+
> Windows Unicode-only collations can only be used with the COLLATE clause to apply collations to the **nchar**, **nvarchar**, and **ntext** data types on column-level and expression-level data; these cannot be used with the COLLATE clause to define or change the collation of a database or server instance.
6159
6260
2. Creating or altering a table column.
6361

64-
You can specify collations for each character string column using the COLLATE clause of the CREATE TABLE or ALTER TABLE statement. You can also specify a collation when you create a table using [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)]. If you do not specify a collation, the column is assigned the default collation of the database.
62+
You can specify collations for each character string column using the COLLATE clause of the `CREATE TABLE` or `ALTER TABLE` statement. You can also specify a collation when you create a table using [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)]. If you do not specify a collation, the column is assigned the default collation of the database.
6563

6664
You can also use the `database_default` option in the COLLATE clause to specify that a column in a temporary table use the collation default of the current user database for the connection instead of **tempdb**.
6765

6866
3. Casting the collation of an expression.
6967

7068
You can use the COLLATE clause to apply a character expression to a certain collation. Character literals and variables are assigned the default collation of the current database. Column references are assigned the definition collation of the column.
7169

72-
The collation of an identifier depends on the level at which it is defined. Identifiers of instance-level objects, such as logins and database names, are assigned the default collation of the instance. Identifiers of objects within a database, such as tables, views, and column names, are assigned the default collation of the database. For example, two tables with names different only in case may be created in a database with case-sensitive collation, but may not be created in a database with case-insensitive collation. For more information, see [Database Identifiers](../../relational-databases/databases/database-identifiers.md).
70+
The collation of an identifier depends on the level at which it is defined. Identifiers of instance-level objects, such as logins and database names, are assigned the default collation of the instance. Identifiers of objects within a database, such as tables, views, and column names, are assigned the default collation of the database. For example, two tables with names different only in case may be created in a database with case-sensitive collation, but may not be created in a database with case-insensitive collation. For more information, see [Database Identifiers](../../relational-databases/databases/database-identifiers.md).
7371

74-
Variables, GOTO labels, temporary stored procedures, and temporary tables can be created when the connection context is associated with one database, and then referenced when the context has been switched to another database. The identifiers for variables, GOTO labels, temporary stored procedures, and temporary tables are in the default collation of the server instance.
72+
Variables, GOTO labels, temporary stored procedures, and temporary tables can be created when the connection context is associated with one database, and then referenced when the context has been switched to another database. The identifiers for variables, GOTO labels, temporary stored procedures, and temporary tables are in the default collation of the server instance.
7573

76-
The COLLATE clause can be applied only for the **char**, **varchar**, **text**, **nchar**, **nvarchar**, and **ntext** data types.
74+
The COLLATE clause can be applied only for the **char**, **varchar**, **text**, **nchar**, **nvarchar**, and **ntext** data types.
7775

78-
COLLATE uses *collate_name* to refer to the name of either the SQL Server collation or the Windows collation to be applied to the expression, column definition, or database definition. *collation_name* can be only a specified *Windows_collation_name* or a *SQL_collation_name* and the parameter must contain a literal value. *collation_name* cannot be represented by a variable or expression.
76+
COLLATE uses *collate_name* to refer to the name of either the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] collation or the Windows collation to be applied to the expression, column definition, or database definition. *collation_name* can be only a specified *Windows_collation_name* or a *SQL_collation_name* and the parameter must contain a literal value. *collation_name* cannot be represented by a variable or expression.
7977

80-
Collations are generally identified by a collation name, except in Setup. In Setup, you instead specify the root collation designator (the collation locale) for Windows collations, and then specify sort options that are sensitive or insensitive to case or accents.
78+
Collations are generally identified by a collation name, except in Setup. In Setup, you instead specify the root collation designator (the collation locale) for Windows collations, and then specify sort options that are sensitive or insensitive to case or accents.
8179

82-
You can execute the system function [fn_helpcollations](../../relational-databases/system-functions/sys-fn-helpcollations-transact-sql.md) to retrieve a list of all the valid collation names for Windows collations and SQL Server collations:
80+
You can execute the system function [fn_helpcollations](../../relational-databases/system-functions/sys-fn-helpcollations-transact-sql.md) to retrieve a list of all the valid collation names for Windows collations and SQL Server collations:
8381

8482
```sql
8583
SELECT name, description
8684
FROM fn_helpcollations();
8785
```
8886

89-
[!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] can support only code pages that are supported by the underlying operating system. When you perform an action that depends on collations, the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] collation used by the referenced object must use a code page supported by the operating system running on the computer. These actions can include the following:
87+
[!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] can support only code pages that are supported by the underlying operating system. When you perform an action that depends on collations, the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] collation used by the referenced object must use a code page supported by the operating system running on the computer. These actions can include the following:
9088

9189
- Specifying a default collation for a database when you create or alter the database.
9290

@@ -95,7 +93,7 @@ FROM fn_helpcollations();
9593
- When restoring or attaching a database, the default collation of the database and the collation of any **char**, **varchar**, and **text** columns or parameters in the database must be supported by the operating system.
9694

9795
> [!NOTE]
98-
> Azure SQL Database Managed Instance server collation is **SQL_Latin1_General_CP1_CI_AS** and cannot be changed.
96+
> [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)] Managed Instance server collation is **SQL_Latin1_General_CP1_CI_AS** and cannot be changed.
9997
10098
> [!NOTE]
10199
> Code page translations are supported for **char** and **varchar** data types, but not for **text** data type. Data loss during code page translations is not reported.
@@ -105,7 +103,7 @@ FROM fn_helpcollations();
105103
106104
## Examples
107105

108-
### A. Specifying collation during a select
106+
### A. Specifying collation during a SELECT
109107
The following example creates a simple table and inserts 4 rows. Then the example applies two collations when selecting data from the table, demonstrating how `Chiapas` is sorted differently.
110108

111109
```sql

0 commit comments

Comments
 (0)