游客发表

SQL Server数据库内容替换方法

发帖时间:2025-11-05 04:47:33

declare @ptr varbinary(16)

declare @artId int

SQL Server数据库内容替换方法

declare @Position int,据库@len int

set @len = datalength(老字符串)

declare wux_Cursor scroll Cursor

for

select textptr([字段名]),[key字段名] from [数据表名]

for read only

open wux_Cursor

fetch next from wux_Cursor into @ptr,@artId

while @@fetch_status=0

begin

select @Position=patindex(%老字符串%,[字段名]) from [数据表名] where [key字段名]=@artId

while @Position>0

begin

set @Position=@Position-1

updatetext [数据表名].[字段名] @ptr @Position @len 新字符串

select @Position=patindex(%老字符串%,[字段名]) from [数据表名] where [key字段名]=@artId

end

fetch next from wux_Cursor into @ptr,@artId

end

close wux_cursor

deallocate wux_cursor

go

    热门排行

    友情链接