How to set collation of a column with SQL?
To change the database's collation
ALTER DATABASE MyDataBase COLLATE [NewCollation]
To change the collation of a column
ALTER TABLE MyTable ALTER COLUMN Column1 [TYPE] COLLATE [NewCollation]
But there are a number of limitations on when you can do this, very notably that this is denied if the column is used in any index.
You can do more in SSMS in some cases.
The syntax docs list the restrictions:
- https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-table-transact-sql?view=sql-server-2017
- https://docs.microsoft.com/en-us/sql/t-sql/statements/collations?view=sql-server-2017
I tried this code and it's working for me :
ALTER TABLE dbo.MyTable
ALTER COLUMN CharCol VARCHAR(50) COLLATE Latin1_General_100_CI_AI_SC_UTF8
reference : https://docs.microsoft.com/en-us/sql/relational-databases/collations/set-or-change-the-column-collation?view=sql-server-ver15