Description:
Function:
In this example we explain that how to remove non
numeric character from string in SQL Server.or fetch the string without non
alphabet character or removing non numeric character from string using SQL
Server function.
Here we create one SQL Server user defined function
that will return string or text with removing non numeric character in SQL
Server.here we simply input the value to SQL Server function and it will
returns the string or value with removing non numeric character.
So below is the SQL Server user defined function
that will remove non numeric characters from the given input value.
CREATE Function [dbo].[RemoveNonNumaricCharacters](@Val VarChar(1000))
Returns VarChar(1000)
AS
Begin
Declare
@RegExp as varchar(50)
Set @RegExp
= '%[^0-9]%'
While PatIndex(@RegExp, @Val) > 0
Set
@Val = Stuff(@Val, PatIndex(@RegExp, @Val), 1, '')
Return @Val
End
--Execute
Query After Create above Function
SELECT dbo.RemoveNonNumaricCharacters('Kirit How r U ? 123')
Good Job....
ReplyDeletethanks and also visit blog for new article update.
Delete