カーソル操作


--
 --

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