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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update a partial string

Author  Topic 

darthelvis
Starting Member

3 Posts

Posted - 2012-12-28 : 08:57:30
I am trying to update part of a string for dozens of entries in a table with CN instead of NC and it doesn't appear to be working. e.g. Trying to change entry NC - 2010 - 000018 so it now reads CN - 2010 - 000018

UPDATE TABLE
SET column = replace(column, 'NC%', 'CN%')
WHERE column LIKE 'NC%';

Is this possible? Am I missing some coding somewhere? I'm using SQL developer.

Any help would be greatly appreciated.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-12-28 : 09:04:02
I'm not sure how to do it oracle, but in SQL Server, it' be this

UPDATE TABLE
SET column = replace(column, 'NC', 'CN')
WHERE column LIKE 'NC%';

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

darthelvis
Starting Member

3 Posts

Posted - 2012-12-28 : 10:38:22
Excellent thanks Jim that worked a treat!
Go to Top of Page
   

- Advertisement -