I\'m trying to strip out the \"(\", \")\", \"-\", \"x\" or \"X\" \"ext\" and spaces from each phone number so I am left with only the first 10 digits or 1st 10 numbers of a
See if this works:
Declare @Expression varchar(15)
Declare @MyVariable varchar(20)
Set @Expression = '%[^0-9]%'
Set @MyVariable = '(555) 555-5555 ext55555'
While PatIndex(@Expression, @MyVariable) > 0
Set @MyVariable = Stuff(@MyVariable, PatIndex(@Expression, @MyVariable), 1, '')
Print @MyVariable
555555555555