Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 1st, 2007, 02:38 PM
Authorized User
 
Join Date: Apr 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default replacing numbers in a string

I'm looking for a quick solution to replace numeric values with a # within a string. The numbers can fall anywhere within the string.
i.e.
123text
1text23
12te3xt

I was hoping there was a function like replace(textname, isnumeric(textname), '#')

Or do I have to loop thru each and every character in the textname to analyze if it is numeric or not.

Help is appreciated.




 
Old April 2nd, 2007, 01:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

IMO, you got to loop through the string and replace it. Or the other way would be to have 10 REPLACE function performed on the string.
Code:
SELECT @VarName = textname from TABLE_NAME ... WHERE ColumnName = Somevalue
Select @VarName = Replace(@VarName, '0', '#')
Select @VarName = Replace(@VarName, '1', '#')
...
...
Select @VarName = Replace(@VarName, '9', '#')
Cheers.

_________________________
- Vijay G
Strive for Perfection
 
Old April 2nd, 2007, 04:47 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 246
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Take a look at these functions found here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=79083


 
Old April 2nd, 2007, 10:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hmmm, That looks a good solution. Good effort.

Cheers.

_________________________
- Vijay G
Strive for Perfection
 
Old April 2nd, 2007, 04:24 PM
Authorized User
 
Join Date: Apr 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks, I figured there was no other way.
regards,
C






Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing multiple characters in a string philboparker BOOK: XSLT Programmer's Reference, 2nd Edition 0 May 20th, 2008 04:38 PM
Replacing characters in a string semilemon C# 2005 2 June 16th, 2006 11:31 PM
Replacing a character from string itHighway Classic ASP Basics 5 March 14th, 2005 11:15 PM
Parsing a string of numbers tp194 Classic ASP Databases 1 January 5th, 2004 10:28 AM
Replacing Text with a String in a Form newgeek Beginning VB 6 2 August 14th, 2003 12:37 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.