tags:

views:

39

answers:

2

I am searching for the following string in a nvarchar(max) column

<script src="http://d1.openx.org/ajs.php?zoneid=75288&amp;amp;source

However when I use CharIndex and try to find, I get 0

How can I search for that string? I am using SQL 2008

+1  A: 

This works fine for me. Are you sure you have the parameters in the right order?

create table #t
(test nvarchar(max))


insert #t 
select 'abcdefghijklmnop<script src="http://d1.openx.org/ajs.php?zoneid=75288&amp;amp;source12345'



select charindex('<script src="http://d1.openx.org/ajs.php?zoneid=75288&amp;amp;source',test,0)
from #t
Ed Harper
A: 

I would add that if this is database cleanup, you can use REPLACE to change things around easily.

you might check that your data doesn't have an < instead of <

way0utwest