Using PATINDEX to find character in a string.  

Posted by ReelTym

declare @test table ( id int identity(1,1) primary key clustered, value varchar(10) )

insert into @test (value)
    select null union all
    select '' union all
    select '1' union all
    select '-' union all
    select '1.2' union all
    select '1,23' union all
    select ',' union all
    select '.'

select * from @test where patindex( '%[,.-]%', value ) > 0

-- Should return

id          value
----------- ----------
4           -
5           1.2
6           1,23
7           ,
8           .

This entry was posted on Tuesday, July 12, 2011 and is filed under , . You can leave a response and follow any responses to this entry through the Subscribe to: Post Comments (Atom) .

0 comments