Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
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 (119k 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

0 votes
1 answer
asked Oct 19, 2020 in SQL by dev_sk2311 (45k points)
0 votes
1 answer

Browse Categories

...