求sql 字符替换函数。

wlmfly 2006-08-31 03:05:20
相当vb的 replace()函数的功能,请问有这样的sql函数吗
...全文
824 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
flyrat 2006-09-01
  • 打赏
  • 举报
回复
update ntext:
/*
tbl_name表名
column_name列名
id行号
将@str替换为@des
*/

declare @pos int
declare @len int
declare @str nvarchar(4000)
declare @des nvarchar(4000)
declare @count int
set @des ='<requested_amount+1>'
set @len=len(@des)
set @str= '<requested_amount>'

set @count=0--统计次数.

WHILE 1=1
BEGIN
select @pos=patINDEX('%'+@des+'%',column_name) - 1
from tbl_name
where id=2093


IF @pos>=0
begin
DECLARE @ptrval binary(16)
SELECT @ptrval = TEXTPTR(column_name)
from tbl_name
where id=2093
UPDATETEXT tbl_name.column_name @ptrval @pos @len @str
set @count=@count+1
end
ELSE
break;
END

select @count
QuinsonYue 2006-08-31
  • 打赏
  • 举报
回复
试试不就知道了 应该可以吧 不可以就转类型
wlmfly 2006-08-31
  • 打赏
  • 举报
回复
ntext的类型的数据 无法用replace()吗
wym840713 2006-08-31
  • 打赏
  • 举报
回复
SELECT REPLACE('abcdefghicde','cde','xxx')
GO
用xxx替换abcdefghicde中的cde
francis901 2006-08-31
  • 打赏
  • 举报
回复
REPLACE(<string_expression1>,<string_expression2>,<string_expression3>)
九斤半 2006-08-31
  • 打赏
  • 举报
回复
SQL也有REPLACE

REPLACE(CHAR1,CHAR2,CHAR3)
wym840713 2006-08-31
  • 打赏
  • 举报
回复
有的 也是replace()

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧