在查询器里执行以下这句SQL语句,出错了,提示:函数 replace 的参数 1 的数据类型 ntext 无效。
english_details是ntext类型的,如果我要将english_details里含有"<p>"的字符替换成空的字符,要怎么修改.
谢谢.
UPDATE product SET english_details=REPLACE(english_details,'''+<p>+''','''')
english_details是ntext类型的,如果我要将english_details里含有"<p>"的字符替换成空的字符,要怎么修改.
谢谢.
UPDATE product SET english_details=REPLACE(english_details,'''+<p>+''','''')
解决方案 »
- 请指点:有2个人员表,1个是常规表,1个是归档表,给定1堆条件,怎样确定在哪个表?
- sql查询int型数据
- 诚聘ASP.Net/C#工程师,B/S项目(北京)
- 老问题新谈:如何用SQL 命令 暂时 停止产生日志 和 恢复产生日志?
- 又提问啦!有测试例子=>找出不是独身子女,并且不是最大的孩子
- 在存储过程中如何根据|这样特定字符,查找数据
- The element 'xs:schema' is used but not declared in the DTD/Schema
- sql2000 插入 不要提示
- IIS does not seem to be running on this computer
- 数据库附加错误
- 送分了!关于SQL2005的驱动问题!
- 服务端跟客户端分开的跟个人版的差不多吗
create table product (id int identity,english_details ntext)
insert into product select 'abc<p>axe<p>,asd'
union all select 'a01t<p>ce4<p>56d'--定义替换的字符串
declare @s_str varchar(8000),@d_str varchar(8000)
select @s_str='<p>' --要替换的字符串
,@d_str='' --替换成的字符串--字符串替换处理
declare @p varbinary(16),@postion int,@rplen int,@i int
set @i = 1
while @i <= (select count(*) from product)
begin
select @p=textptr(english_details),@rplen=len(@s_str),@postion=charindex(@s_str,english_details)-1 from product
where id = @i
while @postion>0
begin
updatetext product.english_details @p @postion @rplen @d_str
select @postion=charindex(@s_str,english_details)-1 from product where id = @i
end
set @i = @i + 1
end--显示结果
select * from productid english_details
---------------------------
1 abcaxe,asd
2 a01tce456d
UPDATE product SET english_details=REPLACE(english_details,' <p>','')
谢谢各位了.特别是ydage
我是这样写的:
UPDATE product set china_details=replace(cast(china_details as varchar(8000)) ,'<p>',' ')用cast来转换一下.