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 Kodyaz SQL Server and T-SQL Development Tutorials
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Windows, Windows Phone, SAP and ABAP, like SAP UI5, Screen Personas, etc.




download SQL Server 2016
download SQL Server 2014
download SQL Server 2012



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

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

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

remove numeric characters in a string expression using SQL function







Related SQL Resources

SQL Server Articles

SQL Server 2012

SQL Server Tools

SQL Blog

SQL Server 2008 Blog

Certification Exams Blog

Reporting Services Blog

Analysis Services Blog

MS SQL Server Forums






SQL Split String Related SQL Server Tutorials

Split String using XML - How to Convert or Split a Delimited String Values to Rows using T-SQL XML Commands
Split String Into Fixed Length Pieces in SQL
Recursive Function Sample - MS SQL Server Recursive T-SQL Split Function
TSQL Character Split Function in SQL Server
Case Sensitive SQL Split Function
SQL Server 2016 Split String Function STRING_SPLIT
SQL Server String Split T-SQL CLR Function Sample
SQL Server CLR Split String Function for 2-Dimensional Array
T-SQL Split User Defined Function


Copyright © 2004 - 2017 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems