Case Inensitive Query on a Case Sensitive Column in SQL Server

In this example we will use the following table with one case sensitive column:

ci_query_result_contents

When we query data from a case sensitive (CS) table column in SQL Server, we get the following result:

SELECT * FROM ci_test
WHERE Text = 'Abc'

cs_query_result_2

To do a case insensitive (CI) search on a case sensitive table column, use the following query:

SELECT * FROM ci_test
WHERE Text COLLATE SQL_Latin1_General_CP1_CI_AS = 'Abc'

ci_query_result_2

Column can be made case insensitive when table is designed, using the following query:
CREATE TABLE ci_test (Text nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS)

Querying a column that was designed as case insensitive will be case insensitive:

ci_column_query_result

If the post helped you, please share it:
Pin It

1 comment to Case Inensitive Query on a Case Sensitive Column in SQL Server

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">