SQL Server has no [regular expression] functionality like that. You can
nest REPLACEs in there, and make it a UDF:
WHERE
dbo.cleanPhone(phone) = '#phone_just_numbers#'
-- only works in SQL 2K
CREATE FUNCTION dbo.cleanPhone(
@num varchar(20)
)
RETURNS varchar(20)
AS
BEGIN
RETURN
REPLACE(
REPLACE(
REPLACE(
REPLACE(@num, '(', '') -- replace (
, ')', '') -- replace )
, '-', '') -- replace -
, ' ', '') -- replace spaces
END
David L. Penton, Microsoft MVP
JCPenney Application Specialist / Lead
"Mathematics is music for the mind, and Music is Mathematics for the
Soul. - J.S. Bach"
[EMAIL PROTECTED]
Do you have the VBScript Docs or SQL BOL installed? If not, why not?
VBScript Docs: http://www.davidpenton.com/vbscript
SQL BOL: http://www.davidpenton.com/sqlbol
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of
Ricardo Sanoja
I am looking for a function for SQL Server 2000 that will strip out all but
numbers from the left side of the equation.
Example
Select cust_id,phone
>From customers
Where stripchar(phone) = �#phone_just_numbers#�
Before anyone asks, I know that stripchar is not a real function, what I
need is a function that performs the task of just looking at the numbers.
Sincerely,
Ricardo M. Sanoja
Senior Web Architect
4288 Kellway Circle
Addison, TX. 75001
972.267.1558 Ext. 219
mailto:[EMAIL PROTECTED]
-------------------------------------------------------------------------
This email server is running an evaluation copy of the MailShield anti-
spam software. Please contact your email administrator if you have any
questions about this message. MailShield product info: www.mailshield.com
-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org