0

I need to concatenate 2 rtf fields stored in 2 separate blob columns (actually they are nvarbinary(max) in sql server).

I need to do this with a database script, not in an application.

Is there a way? Or the only solution is to remove all the rtf headers, concatenate the "body" of the 2 fields and then recreate the headers?

By headers I mean

\rtf1\ansi\ etc...
UnDiUdin
  • 14,924
  • 39
  • 151
  • 249

1 Answers1

2

If you can cleanly remove the headers and fix any CRC/length issues, then a simply string concat (which is valid for binary types too) will do it

eg

NewFixedHeader + HeaderlessnNarbinarymaxcolumn1 + HeaderlessNvarbinarymaxcolumn2

Although, this isn't really a SQL thing at all...

gbn
  • 422,506
  • 82
  • 585
  • 676
  • yes, removing headers will take time and test, of course a built in sql server stored procedure for concatenating fields would be great, but afaik this doesn't exist. One can of course create one, but it will be for sure bufgul. – UnDiUdin Jun 24 '10 at 11:53
  • I mean concatenating rtf fields – UnDiUdin Jun 24 '10 at 14:25
  • No, you can't concat rtf because it isn't a SQL datatype. You need to to do what I said: concat a new header with the 2 data portions of the 2 rtfs. You can't simply join two blobs that are RTF. – gbn Jun 24 '10 at 20:15
  • Ok, it is a pity anyway that no RDBMS supports handling of rtf fields for simple operations like "extract text" and "concatenate". – UnDiUdin Jun 30 '10 at 08:17