Convert Text Case without Changing SQL Server Comparison Rules

UPPER and LOWER transform text in a result without requiring an update to the stored value. This is useful for display labels and exports. Whether a comparison distinguishes uppercase from lowercase is a separate decision controlled by collation.

Transform a Result

SQL
SELECT OriginalValue,
       UPPER(OriginalValue) AS UpperValue,
       LOWER(OriginalValue) AS LowerValue
FROM (VALUES (N'Blue Pump'), (N'Valve A')) AS v(OriginalValue);

The first row returns Blue Pump, BLUE PUMP and blue pump. These are expressions in the result. No source row changes.

Use an N prefix for Unicode string literals, and choose character types suitable for your data. Case conversions can depend on language and collation, so test representative non-English text rather than assuming ASCII rules cover every name.

Make Comparison Semantics Explicit

SQL
SELECT
    CASE WHEN N'pump' COLLATE Latin1_General_100_CI_AS = N'PUMP'
         THEN 1 ELSE 0 END AS CaseInsensitiveMatch,
    CASE WHEN N'pump' COLLATE Latin1_General_100_CS_AS = N'PUMP'
         THEN 1 ELSE 0 END AS CaseSensitiveMatch;

The result is 1 and 0. These expression-level collations demonstrate the difference without altering a database or column. The appropriate production collation must also suit the language and accent rules you need.

Keep Search and Storage Decisions Separate

For a column already using a suitable case-insensitive collation, a normal equality predicate can match different letter cases without wrapping the column in UPPER. Applying functions to the indexed column can make an efficient search harder. An expression-level collation change can also affect plan choices, so inspect the plan for important queries.

Avoid blanket updates that uppercase people's names or other original text merely to support searching. That loses presentation information. If a stored normalized value is genuinely required, define the normalization contract, preview affected rows, and use a separately reviewed update with a rollback plan.

Microsoft References

Author: Herman Schoenfeld