SQL Server - Most Efficient Way to Replace Multiple String Patterns -


i need clean string field , replace dozen different patterns. know can use nested replace function, doing lot real pain type , makes ugly code.

is there more efficient way this?

you can nested replace . . . without nesting. here 1 method:

select t.*, t_r12.col_r t outer apply      (select replace(t.col, 'in1', 'out1') col_r) t_r01 outer apply      (select replace(t_r01.col_r, 'in2', 'out2') col_r) t_r02 outer apply      (select replace(t_r02.col_r, 'in3', 'out3') col_r) t_r03 outer apply      . . .; 

in context, don't think outer apply adds (significant) overhead. however, require naming intermediate results.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -