SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for ASP.Net, SQL Server, Reporting Services, T-SQL, Windows, AWS, SAP HANA and ABAP


Remove Numeric Characters in String using SQL

SQL programmers can remove numeric characters in string expressions using SQL to fetch remaining character values only as shown in this database programming tutorial. I'll share a user defined SQL function (UDF) which can be used to clear numeric values in a given character expression, variable or database table field.

Below is the source codes of the UDF user-defined SQL function ClearNumericCharacters() which can be used for clearing numeric values and fetching only the characters from a string expression.

create function ClearNumericCharacters(@string nvarchar(max))
returns nvarchar(max)
as
begin
 while patindex('%[0-9]%', @string) > 0
  set @string = stuff(@string, patindex('%[0-9]%', @string), 1, '')
 return @string
end
Code

Above SQL function is a slightly different version of the SQL Server function for removing non-numeric characters in SQL.

SQL function to clear numeric characters from a string

SQL Server developers can use ClearNumericCharacters() SQL user defined function as seen in below code samples in their programs to replace or delete numeric characters in string expressions.

select dbo.ClearNumericCharacters('Number1Kodyaz26=>SQL')

select StringValue, dbo.ClearNumericCharacters(StringValue)
from StringExpressions
Code

Outputs of SQL function ClearNonNumericCharacters() execution with sample data:

remove numeric characters in a string expression using SQL function



SQL Server

SQL Server 2019 Installation
download SQL Server 2019
download SQL Server 2017
download SQL Server 2016
download SQL Server 2014
download SQL Server 2012
MacOS ve SQL Server 2019


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.