SomaFM commercial free internet radio All posts tagged 'TSQL'

Paul Sturm

My notebook of discovered facts

Remove characters from a column

I needed to scrub a column of power meters.  I needed to remove certain characters that had found their way into the system.

SELECT  dbo.site.power_meter

      , REPLACE(REPLACE(REPLACE(REPLACE(dbo.node.power_meter, ' ', ''), '-',

                                ''), '/', ''), '.', '') AS better_power_meter

FROM    dbo.node

This was fast enough on a under a hundred thousand rows. You might want to try using CLR with RegEx if you have billions to clean.


Categories: SQL Server | TSQL
Permalink | Comments (43) | Post RSSRSS comment feed