Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
midan1
Starting Member
39 Posts |
Posted - 2008-04-14 : 18:39:23
|
need help replace characters on condition in table and cellsbut only if if i put number or 1 , 2 , 3 , 4 above the cell of the eployee for example( employee id=222 name =bbbb day1)i replace characters with '0' and '#'and it must work dynamically AND replace ONLY THIS characterstable before the replaceid fname val day1 day11 day111 day2 day22 day222 ------------------------------------------------------111 aaaa 2 1 3 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 replaceid 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 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-14 : 18:45:41
|
UPDATE Table1SET day1 = CASE WHEN day1 IS NULL THEN NULL WHEN day1 NOT LIKE '%[^0-9]%' THEN 0 ELSE '#' END,day11 = CASE WHEN day11 IS NULL THEN NULL WHEN day11 NOT LIKE '%[^0-9]%' THEN 0 ELSE '#' END,day111 = CASE WHEN day111 IS NULL THEN NULL WHEN day111 NOT LIKE '%[^0-9]%' THEN 0 ELSE '#' END,day2 = CASE WHEN day2 IS NULL THEN NULL WHEN day2 NOT LIKE '%[^0-9]%' THEN 0 ELSE '#' END,day22 = CASE WHEN day22 IS NULL THEN NULL WHEN day22 NOT LIKE '%[^0-9]%' THEN 0 ELSE '#' END,day222 = CASE WHEN day222 IS NULL THEN NULL WHEN day222 NOT LIKE '%[^0-9]%' THEN 0 ELSE '#' END E 12°55'05.25"N 56°04'39.16" |
|
|
midan1
Starting Member
39 Posts |
Posted - 2008-04-14 : 18:53:26
|
tnx Pesobut i need only to replacenot updatehow ?tnx |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-14 : 18:55:37
|
Replace content of a "field" is done by UPDATE. E 12°55'05.25"N 56°04'39.16" |
|
|
midan1
Starting Member
39 Posts |
Posted - 2008-04-14 : 19:06:51
|
but it must be depending on tow rowsOF THE EMPLOYEEthe employee have tow rowsval=1val=2 not only replace the characters only if i put number or 1 , 2 , 3 , 4 above the cell of the employeeID fname val day1 day11 day111---------------------------------111 aaaa 2 1 3 111 aaaa 1 A C like this condition not work !!!because i don't HAVE number or 1 , 2 , 3 , 4 above THE cellID fname val day1 day11 day111---------------------------------111 aaaa 2 111 aaaa 1 A C tnx |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|
|
|