July 20, 2009 at 5:16 am
Hi I need to replace a memo field called "desc" with itself minus the last four characters.
Somebody has run a process which puts a rude word on the end of the decsriptions
thanks ps its sql server 2000
July 20, 2009 at 6:13 am
two ways...you can use the REPLACE function to replace the bad word with an empty string:
UPDATE MYTABLE SET MYCOLUMN = REPLACE(MYCOLUMN,'BADWORD','')
this is a better solution, because if the bad word does not exist, nothing gets replaced.
If you just whack every column to remove the last 4 characters, you might chop something you didn't really want to do; you'd want to at least use a WHERE statement to test for the bad word:
UPDATE MYTABLE SET MYCOLUMN = LEFT(MYCOLUMN,LEN(MYCOLUMN - 4) WHERE MYCOLUMN LIKE '%BADWORD'
Lowell
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply