Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Proper Case Only If All Caps Expand / Collapse
Author
Message
Posted Tuesday, May 18, 2010 10:52 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, August 3, 2011 7:31 AM
Points: 91, Visits: 423
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! :)
Post #923741
Posted Tuesday, May 18, 2010 11:01 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 8:48 AM
Points: 12,921, Visits: 32,285
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #923747
Posted Tuesday, May 18, 2010 11:18 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, August 3, 2011 7:31 AM
Points: 91, Visits: 423
Thanks so much! That will be perfect!
Post #923760
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse