create procedure #t ( @t1 text , @i1 image, @t2 text, @i2 image, @t3 varchar(30), @i3 varbinary(2) ) as declare @tptr varbinary(16), @iptr varbinary(16), @tpos int, @ipos int create table #blob(id int identity, t text, i image)
insert #blob values(@t1, @i1) select id, convert(varchar(50), t) as text_val, convert(varbinary, i) as image_val from #blob
update #blob set t = @t2, i = @i2 where id = @@identity select id, convert(varchar(50), t) as text_val, convert(varbinary, i) as image_val from #blob
select @tptr = TEXTPTR(t), @tpos = PATINDEX('%TEXT...%', t) - 1, @iptr = TEXTPTR(i), @ipos = 2 from #blob
updatetext #blob.t @tptr @tpos 0 @t3 select id, convert(varchar(50), t) as text_val, convert(varbinary, i) as image_val from #blob
updatetext #blob.i @iptr @ipos 1 @i3 select id, convert(varchar(50), t) as text_val, convert(varbinary, i) as image_val from #blob go
exec #t 'SOME TEXT HERE...', 0x02498765bcde3, 'MODIFIED TEXT...', 0xab86ec64, '(INSERT BEFORE TEXT) ', 0xcd
go drop proc #t go |