Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple SQL Replace Command Help

Status
Not open for further replies.

rwsjbs

Technical User
Oct 22, 2010
12
US
Thanks for looking!

I'm using SQL 2008 Express and need to update a field GCNumber. I'm trying to delete the ; and ? characters so that I'm left with a number.

So the existing string of:
;100335?
Is replaced with:
100335

I know this is very simple, but I'm not able to figure it out.

Please let me know if you can send me a simple SQL statement that would Replace or Trim those characters out.

Thank you,
Richard Scott

 
You'll need to run the replace twice, once for each character. You can nest replaces, like this:

Code:
Select [blue]Replace([/blue][red]Replace([green]GCNumber[/green], '?', '')[/red][blue], ';', '')[/blue]

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top