views:

22

answers:

1

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...
+2  A: 

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
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.
Just use the "+" concatenate operator...
gbn
I mean concatenating rtf fields
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
Ok, it is a pity anyway that no RDBMS supports handling of rtf fields for simple operations like "extract text" and "concatenate".