Showing posts with label find and replace special character in sql server. Show all posts
Showing posts with label find and replace special character in sql server. Show all posts

Check isalphanumeric in sql server

ALTER FUNCTION dbo.ISALPHANUMERIC
(
 @columnfield VARCHAR(5000)
)
RETURNS VARCHAR(5000)
AS
    BEGIN
        DECLARE @splcharposition INT
        SET @splcharposition = PATINDEX('%[^0-9A-Za-z]%', @columnfield)
    WHILE @splcharposition > 0
        BEGIN
            SET @columnfield = STUFF(@columnfield, @splcharposition, 1, '')
            SET @splcharposition = PATINDEX('%[^0-9A-Za-z]%', @columnfield)
        END
        SET @columnfield = @columnfield
    RETURN @columnfield
    END
GO