Below is the function:
create function dbo.CleanThe
String (@theString As nvarchar(500), @NumbrsOnly As bit)
returns nvarchar(500)
as
begin
--define variables
declare @strAlphaNumeric As nvarchar(500)
declare @i As int
declare @strChar As nvarchar(500)
declare @CleanedString As nvarchar(500)
--initiate values
set @CleanedString = ''
set @theString = @theString + ''
--Determine if we are looking for numeric values only or numbers and letters
If @NumbrsOnly = 1
--Used to check for numeric characters.
set @strAlphaNumeric = '0123456789'
Else
--Used to check for numeric characters.
set @strAlphaNumeric = '0123456789abcdefghijklmnopqrstuvwxyzAB ...
Go to the complete details ...