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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Number filter

Author  Topic 

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2009-02-26 : 05:10:42
Hello guys,
whats the best and most efficient way to filter numbers in a SP ?

Am currently using this


set @csv = replace(@csv, 'a','')
set @csv = replace(@csv, 'b','')
set @csv = replace(@csv, 'c','')

etc


and

set @csv = replace(@csv, '£','')
set @csv = replace(@csv, '$','')
set @csv = replace(@csv, '*','')

etc
for non alpha characters.

the other way, I thought about implementing is to use an array of characters and run a split function to check and remove its existence.

thanks
Ehi

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-02-26 : 06:07:07
What is a number?
1234567890
123,123.45
123.00

Greetings
Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2009-02-26 : 06:23:31
intergers

no dots and not commas, simply integers.
Go to Top of Page

heavymind
Posting Yak Master

115 Posts

Posted - 2009-02-26 : 06:41:17
you may use cycle by each symbol from 0 to 255 except the number symbols (using char () function) with replace. or cycle by each symbol of the string and compare it to [0-9].

Thanks, Vadym
MCITP DBA 2005/2008
Chief DBA at http://www.db-staff.com
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-02-26 : 06:50:54
go through this,

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=79083
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2009-02-26 : 07:55:10
quote:
Originally posted by sakets_2000

go through this,

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=79083



thanks a lot, funny, I had seen Madhivanan's blog and that article also.

Would also say good job Peso
Go to Top of Page
   

- Advertisement -