4

I have binary data in specific field in sql server 2008, but i want to append some binary data to the same field. can you help me about that?

Abdullah Zaid
  • 171
  • 3
  • 9

1 Answers1

7

If it is a varbinary(n) / varbinary(max) - you just append with +:

declare @foo table(id int, bar varbinary(max))

insert @foo values(1, 0x01)

declare @newdata varbinary(max) = 0x020304

update @foo set bar = bar + @newdata
where id = 1

select bar from @foo
where id = 1

If you are using image, you can use UPDATETEXT, but it is more involved (read MSDN) - insert_offset of NULL means "append", and specify delete_length of 0.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900