I'm not sure about how large or what exactly is in your dataset but you could simply remove the duplicates and update the data to upper case after. If you have more columns, you can add them to the partition where the pid
column is generated. Not a perfect solution but it gets the job done!
create table #test (
col varchar(50)
)
insert into #test values
('USA')
,('usa')
,('nicaragua')
,('NICARAGUA')
-- Identifying duplicates. They'll have a PID of greater than 1
;with _dupes as
(
select ROW_NUMBER() over (partition by col order by col) pid
,col
from #test
)
-- removing duplicates from data
delete _dupes
where pid > 1
-- updating data to uppercase
update #test
set col = UPPER(col)
select *
from #test
drop table #test