replace characters on condition in table and cell

  • need help

    replace characters on condition in table and cells

    but only if

    if i put number or 1 , 2 , 3 , 4 above the cell of the employee for example( employee id=222 name =bbbb day1)

    i replace characters with '0' and '#'

    and it must work dynamically AND replace ONLY THIS characters

    table before the replace

    id fname val day1 day11 day111 day2 day22 day222

    ------------------------------------------------------

    111 aaaa 2 1 4

    111 aaaa 1 A C

    222 bbbb 2

    222 bbbb 1

    333 cccc 2

    333 cccc 1

    444 dddd 2

    444 dddd 1

    555 eeee 2 2

    555 eeee 1 B

    table after the replace

    id fname val day1 day11 day111 day2 day22 day222

    ------------------------------------------------------

    111 aaaa 2 0 0

    111 aaaa 1 # #

    222 bbbb 2

    222 bbbb 1

    333 cccc 2

    333 cccc 1

    444 dddd 2

    444 dddd 1

    555 eeee 2 0

    555 eeee 1 #

    tnx FOR THE HELP

  • Also asked here: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=100959

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • So you want to udpate data based on the name of a column? Is that right?

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • you could try something like

    UPDATE Employees

    SET Day1= '0'

    WHERE (isnumeric(Day1) =1)

    UPDATE Employees

    SET Day1= '#'

    WHERE (isnumeric(Day1) <>1)

    [/CODE]

    but from the brief look at your table it looks like you have some flaws in your Db design, you could maybe improve it with better tables design and some normalisation.

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

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