question

Joe_Hell avatar image
Joe_Hell asked

detect "%e2%80%8b" in any column of a table

Anybody provide any hints to detect "%e2%80%8b" in any column of a table? Use patindex or ? any help appreciated
t-sql
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Magnus Ahlkvist avatar image Magnus Ahlkvist commented ·
Do you want to find that exact sequence, or does the %-chara represent à wildcard aearch?
1 Like 1 ·
Joe_Hell avatar image Joe_Hell commented ·
exact sequence.
0 Likes 0 ·

1 Answer

·
Kev Riley avatar image
Kev Riley answered
If you want to search for strings containing characters that would otherwise be seen as [pattern matching wildcards][1] (such as %), then you can use the ESCAPE keyword declare @MyTable table (col1 varchar(50)) insert into @MyTable values ('%e2%80%8b') insert into @MyTable values ('stufff%e2%80%8b') insert into @MyTable values ('%e2%80%8bstufff') insert into @MyTable values ('stuff%e2%80%8bstufff') select * from @MyTable where col1 like '%/%e2/%80/%8b%' escape '/' or escape each occurance within `[]` select * from @MyTable where col1 like '%[%]e2[%]80[%]8b%' select * from @MyTable where patindex('%[%]e2[%]80[%]8b%', col1) > 0 [1]: http://msdn.microsoft.com/en-us/library/ms187489.aspx
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.