Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update a partial string
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

darthelvis
Starting Member

3 Posts

Posted - 12/28/2012 :  08:57:30  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
2875 Posts

Posted - 12/28/2012 :  09:04:02  Show Profile  Reply with Quote
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 - 12/28/2012 :  10:38:22  Show Profile  Reply with Quote
Excellent thanks Jim that worked a treat!
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000