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

 All Forums
 Site Related Forums
 Article Discussion
 Update Query in SQL - Needing to Replace wildcard
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mlg0001
Starting Member

1 Posts

Posted - 06/17/2008 :  13:18:43  Show Profile  Reply with Quote
am trying to do an update query in SQL 2k that updates a name field and removes only the pattern of space middle initial space. I do not want it to strip out any additional names in the field. Some of the values in the name field have 2 last names that are not hypenated - I need to keep this the same.
I cannot get SQL to recognize the wildcard pattern I am searching for and remove it.
I want a name like John S Doe to be John Doe. I want a name like John S Doe Smith to update to John Doe Smith. Only single alpha characters between two spaces need to be updated.

madhivanan
Premature Yak Congratulator

India
22755 Posts

Posted - 06/17/2008 :  13:31:19  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote

update your_Table set data =stuff(data,charindex(' ',data),charindex(' ',substring(data,charindex(' ',data)+1,len(data))),'')

Also consider storing first name and last name in seperate columns


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.06 seconds. Powered By: Snitz Forums 2000