You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit dbf2cd3
Browse filesBrowse the repository at this point in the historyBrowse files
You can override the database collation for **char**, **varchar**, **text**, **nchar**, **nvarchar**, and **ntext** data by specifying a different collation for a specific column of a table and using one of the following:
20
20
21
-
- The COLLATE clause of [CREATE TABLE](../../t-sql/statements/create-table-transact-sql.md) and [ALTER TABLE](../../t-sql/statements/alter-table-transact-sql.md). For example:
22
-
23
-
```sql
24
-
CREATETABLEdbo.MyTable (
25
-
IdCol intPRIMARY KEY,
26
-
CharCol VARCHAR(10) COLLATE French_CI_AS NOT NULL
27
-
);
28
-
GO
29
-
ALTERTABLEdbo.MyTable
30
-
ALTER COLUMN CharCol VARCHAR(10) COLLATE Latin1_General_CI_AS NOT NULL;
31
-
GO
32
-
```
33
-
34
-
- [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)]. For more information, [Collation and Unicode Support](../../relational-databases/collations/collation-and-unicode-support.md).
21
+
- The COLLATE clause of [CREATE TABLE](../../t-sql/statements/create-table-transact-sql.md) and [ALTER TABLE](../../t-sql/statements/alter-table-transact-sql.md), as seen in the examples below.
22
+
23
+
-**In-place conversion.** Consider one of the existing tables defined below:
24
+
25
+
```sql
26
+
-- NVARCHAR column is encoded in UTF-16 because a supplementary character enabled collation is used
To convert the column to use UTF-8, copy the data to a new table where the target column is already the required data type and a UTF-8 enabled collation, and then replace the old table:
This method is much faster than in-place conversion, but handling complex schemas with many dependencies (FKs, PKs, Triggers, DFs) and synching the tail of the table (if the database is in use) requires more planning.
69
+
70
+
For more information, see [Collation and Unicode Support](../../relational-databases/collations/collation-and-unicode-support.md).
71
+
72
+
- [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)]. For more information, see [Modify Columns (Database Engine)](../../relational-databases/tables/modify-columns-database-engine.md#SSMSProcedure).
35
73
36
74
- Using the **Column.Collation** property in [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] Management Objects (SMO).
37
75
38
76
You cannot change the collation of a column that is currently referenced by any one of the following:
39
77
40
78
- A computed column
41
-
42
79
- An index
43
-
44
80
- Distribution statistics, either generated automatically or by the `CREATE STATISTICS` statement
45
-
46
81
- A CHECKconstraint
47
-
48
82
- A FOREIGN KEYconstraint
49
83
50
84
When you work with **tempdb**, the [COLLATE](~/t-sql/statements/collations.md) clause includes a *database_default* option to specify that a column in a temporary table uses the collation default of the current user database for the connection instead of the collation of **tempdb**.
0 commit comments