Proper Case Only If All Caps

  • Hello:

    I have a table with a FirstName and LastName field, about 85% of which were entered into the database in proper case (e.g., John Smith, D'Angelo Martin, Jane LaPierre). The rest of the records were entered in all caps. I have a function built to proper case the fields, but I only want to use the function on the records that are in all caps; I want to leave the ones that are already proper cased alone. Does anyone know if there's a way to determine in T-SQL whether a field is in all caps?

    Thanks! 🙂

  • some great code suggestions

    from a similar thread where someone needed to detect if lower case/upper case character exists:

    http://www.sqlservercentral.com/Forums/Topic800271-338-1.aspx

    this would check if the string is all UPPER:

    DECLARE @string VARCHAR(10)

    SET @string = 'Sarat'

    SELECT

    CASE

    WHEN @string = upper (@string) COLLATE Latin1_General_CS_AI

    THEN 'All upper case found' ELSE 'Mixed or lower Case found'

    END

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks so much! That will be perfect! 😀

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply