Perhaps I am missing something but what is wrong with a solution that has no cursors, whiles or UDFs ?
use tempdb
go
Create Table Import_Data_Filter (MyID Int Identity(1,1) NOT NULL, Location varchar(100))
GO
Insert into Import_Data_Filter (Location)
(Select Upper('Mandarin') UNION ALL Select Upper('San Jose') UNION ALL Select Upper('Baymeadows') UNION ALL
Select Upper('My FH Locale') UNION ALL Select Upper('St. Augustine') UNION ALL Select Upper('Test For Three Spaces')
UNION ALL Select Upper('Test for being Four Spaces') UNION ALL Select Upper('Test for being Five More Spaces')
UNION ALL Select Upper('Baymeadows') UNION ALL Select Upper('St. Augustine'))
GO
The simplist SQL:
use tempdb
go
BEGIN TRAN;
UPDATEIDF
SETLocation = Import_Data_Fixed.LocationMixed
FROMImport_Data_Filter as IDF
JOIN(selectMyID
,UPPER(Substring(Location,1,1)) -- First Character is always UPPER CASE
+REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE
(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE
(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
LOWER(SUBSTRING(Location,2,100))
, ' a', ' A'), ' b', ' B'), ' c', ' C'), ' d', ' D'), ' e', ' E'), ' f', ' F')
, ' g', ' G'), ' h', ' H'), ' i', ' I'), ' j', ' J'), ' k', ' K'), ' l', ' L')
, ' m', ' M'), ' n', ' N'), ' o', ' O'), ' p', ' P'), ' q', ' Q'), ' r', ' R')
, ' s', ' S'), ' t', ' T'), ' u', ' U'), ' v', ' V'), ' w', ' W'), ' x', ' X')
, ' y', ' Y'), ' z', ' Z')
as LocationMixed
fromImport_Data_Filter
) AS Import_Data_Fixed
onImport_Data_Fixed.MyID= IDF.MyID
AND Import_Data_Fixed.LocationMixed <> IDF.Location
;
select * from Import_Data_Filter;
rollback;
SQL = Scarcely Qualifies as a Language