Create FUNCTION [dbo].[fnRemoveBadCharacter]
(
@BadString nvarchar(40)
)
RETURNS nvarchar(40)
AS
BEGIN
DECLARE @npos INTEGER
SELECT @npos = PATINDEX('%[^a-zA-Z0-9_]%', @BadString)
WHILE @npos > 0
BEGIN
SELECT @BadString = STUFF(@BadString, @npos, 1, '')
SELECT @npos = PATINDEX('%[^a-zA-Z0-9_]%', @BadString)
END
This is the function I have created to remove bad characters.
How do I call this function to update col1(nvarchar(40)) of tbl1 to remove bad characters?