0 votes
1 view
in SQL by (20.3k points)

How do you compare strings so that the comparison is true only if the cases of each of the strings are equal as well? For example:

Select * from a_table where attribute = 'k'

...will return a row with an attribute of 'K'. I do not want this behavior.

1 Answer

0 votes
by (86.8k points)

You can use the following SQL query to change the column of the table as case-sensitive:

ALTER TABLE a_table

ALTER COLUMN column_name VARCHAR(200)

COLLATE SQL_Latin1_General_CP1_CS_AS

And, if you wish to change the column to case insensitive, you can use the following SQL query:

ALTER TABLE a_table

ALTER COLUMN column_name VARCHAR(200)

COLLATE SQL_Latin1_General_CP1_CI_AS

You can enroll in this SQL Training course to learn such tips and tricks of SQL

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...