Welcome to 2PTTechnology Sign in | Join
in Search

Remove non alpha numeric characters from string

Last post 10-18-2007, 12:37 PM by pskobel. 0 replies.
Sort Posts: Previous Next
  •  10-18-2007, 12:37 PM 61

    Remove non alpha numeric characters from string

    declare @value varchar(50)
    declare @i int

    set @value = '123-bb-99'

    select @i = patindex('%[^a-zA-Z0-9 ]%', @value)
    while @i > 0
    begin
     select @value = replace(@value, substring(@value, @i, 1), '')
     select @i = patindex('%[^a-zA-Z0-9 ]%', @value)
    end

    select @value

    --- returns = 123bb99

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems