Wednesday, March 28, 2012

Remove Character from a table?

I have a table that has several entries.
Some of these entries have $ in them.
I don't want to manually go through all of these and remove the $, so I'm
wondering if there's an easy way to do this with a script or something?
Thanks,
Terry"Terry Matthews" wrote:

>I have a table that has several entries.
> Some of these entries have $ in them.
> I don't want to manually go through all of these and remove the $, so I'm
> wondering if there's an easy way to do this with a script or something?
> Thanks,
> Terry
I believe you want to update using the REPLACE function...
UPDATE SomeTable
SET SomeField = REPLACE(SomeField, '$', '')
WHERE SomeField LIKE '%$%'
Craig|||Terry Matthews (nospam@.hotmail.com) writes:
> I have a table that has several entries.
> Some of these entries have $ in them.
> I don't want to manually go through all of these and remove the $, so I'm
> wondering if there's an easy way to do this with a script or something?
UPDATE tbl
SET col = replace(col, '$', '')
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Great thanks, worked perfectly.
Just put in the column name instead of "somefield"
Thanks
Terry
"Craig Kelly" <cnkelly@.spamnomore.worldnet.att.net> wrote in message
news:gJS9f.11244$qk4.5037@.bgtnsc05-news.ops.worldnet.att.net...
> "Terry Matthews" wrote:
>
> I believe you want to update using the REPLACE function...
> UPDATE SomeTable
> SET SomeField = REPLACE(SomeField, '$', '')
> WHERE SomeField LIKE '%$%'
> Craig
>

No comments:

Post a Comment