简体   繁体   English

在Nvarchar中搜索(最大值)

[英]Searching in Nvarchar(max)

I am searching for the following string in a nvarchar(max) column 我正在nvarchar(max)列中搜索以下字符串

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

However when I use CharIndex and try to find, I get 0 但是,当我使用CharIndex并尝试查找时,我得到0

How can I search for that string? 如何搜索该字符串? I am using SQL 2008 我正在使用SQL 2008

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;source12345'



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

I would add that if this is database cleanup, you can use REPLACE to change things around easily. 我要补充一点,如果这是数据库清理,则可以使用REPLACE轻松更改周围的内容。

you might check that your data doesn't have an < instead of < 您可能会检查数据中是否没有<而不是<

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM