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://learn.microsoft.com/en-us/sql/t-sql/statements/alter-table-transact-sql?view=sql-server-2017
  • https://learn.microsoft.com/en-us/sql/t-sql/statements/collations?view=sql-server-2017

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)