SQL Server - How to convert the first next char to uppercase after the '/' sign -
i have question on how convert first next char uppercase after '/' sign in string.
as example :
customername
: ramayanan s/o vicky ratnam
first need in propercase, use :
update dbo.table set customername = dbo.propercase(customername)
result : ramayanan s/o vicky ratnam
but need : ramayanan s/o vicky ratnam
(the first char after /
should in uppercase
)
please check:
declare @t table(insurance varchar(max)) insert @t values ('roeselare') insert @t values ('brugge') insert @t values ('ramayanan s/o vicky ratnam') select ( select upper(t.n.value('.', 'char(1)'))+ lower(stuff(t.n.value('.', 'varchar(max)'), 1, 1, ''))+(case when right(t.n.value('.', 'varchar(max)'), 1)='/' '' else ' ' end) x.insxml.nodes('/n') t(n) xml path(''), type ).value('.', 'varchar(max)') insurance ( select cast('<n>'+replace( replace( insurance, '/', '/</n><n>'), ' ', '</n><n>')+'</n>' xml) insxml @t ) x
Comments
Post a Comment