How to replace - with _

  • Hello,

    We have a table with roughly 5k reocrds, 3 columns which are Id, ChildDescription, ChildValue

    ChildValue has values like the following

    bracket-clocks

    clock-parts

    cuckoo-clocks

    I need a script which will go through all of the child values and replace the - with _ so the end result would look like

    bracket_clocks

    clock_parts

    cuckoo_clocks

    I'm not a DBA I have minimal experience with SQL due to being a front end developer so any help would be appreciated.

  • Have you tried pressing F1 and looking for REPLACE? You should get to this nice article:

    http://msdn.microsoft.com/en-us/library/ms186862(v=sql.110).aspx

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • update tblname set ChildValue = replace(ChildValue ,'-','_')

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply