Is it possible to change the default collation based on a column? i want to make 1 column case sensitive but all the others not
You can also make column case sensitive by changing column's collation from case insensitive SQL_Latin1_General_CP1_CI_AI to case sensitive Latin1_General_CS_AS. Lets use Alter Command to change the column Name collation from case insensitive to case sensitive.
The SQL keywords are case insensitive ( SELECT , FROM , WHERE , etc), but they are often written in all caps. However, in some setups, table and column names are case sensitive. MySQL has a configuration option to enable/disable it.
Column, index, stored routine, and event names are not case-sensitive on any platform, nor are column aliases. However, names of logfile groups are case-sensitive. This differs from standard SQL.
The SQL keywords (SELECT, FROM, WHERE, etc.) are case-insensitive, yet they are frequently expressed in all capitals. Table and column names are case-sensitive in some settings. MySQL provides a setting that allows you to enable or disable it.
ALTER TABLE ALTER COLUMN
allows to change collation for a single column:
alter table Foo alter column Bar ntext collate Latin1_General_CS_AS
(collation might be incorrect)
I don't specifically know SQL Server, but the generally accepted DBMS practice (for compatibility) would be to either:
There may be a faster way to do it in SQL Server but you should be careful of solutions that push workload into the SELECT statements - they never scale well. It's almost always better doing this as part of inserts and updates since that's the only time data changes - doing it that way minimizes the extra workload.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With