Alex Rivera | Logout

How do I perform a case-sensitive search and replace in SQL 2000/2005?

Asked 2008-09-22T09:02:10.797
21

In order to perform a case-sensitive search/replace on a table in a SQL Server 2000/2005 database, you must use the correct collation.

How do you determine whether the default collation for a database is case-sensitive, and if it isn't, how to perform a case-sensitive search/replace?

Edit
Report

1 Answer

0

You can either specify the collation every time you query the table or you can apply the collation to the column(s) permanently by altering the table.

If you do choose to do the query method its beneficial to include the case insensitive search arguments as well. You will see that SQL will choose a more efficient exec plan if you include them. For example:

SELECT testColumn FROM testTable 
    WHERE testColumn COLLATE Latin1_General_CS_AS = 'eXaMpLe' 
    and testColumn = 'eXaMpLe'
answered 2008-10-24T01:29:28.513

Your Answer