-- 测试表--
create table xinwen(
id int identity primary key ,
nr nvarchar ( 500 )
)
-- 测试数据--
insert into xinwen values ( ' tupian/1.jpg ' )
insert into xinwen values ( ' tupian/2.jpg ' );
insert into xinwen values ( ' tupian/3.jpg ' );
GO
-- 利用游标和Replace函数实现你的需求--
declare aa cursor for
select id,nr
from xinwen
open aa
declare @content nvarchar ( 500 ), @id int , @newContent nvarchar ( 500 )
fetch next from aa into @id , @content
while ( @@fetch_status = 0 )
begin
set @newContent = REPLACE ( @content , ' tupian/ ' , ' http://www.xxxxx.com/tupian/ ' )
update xinwen set nr = @newContent where id = @id
fetch next from aa into @id , @content
end
close aa
deallocate aa
GO
游标操作
最新推荐文章于 2024-12-31 19:26:26 发布