I have a SQL Server 2008 database, with a VARCHAR(MAX) FILESTREAM column. I can load a record into it using this syntax:
`INSERT INTO DocumentRepository(DocumentExtension, DocumentName, Document)
SELECT
'doc' AS DocumentExtension
, 'Hamlet.doc' AS DocumentName
, * FROM OPENROWSET(BULK 'D:\Docs\Hamlet.doc', SINGLE_BLOB)
AS Document;`
This loads my word document just fine. What I'd like to know is how to extract the data back to disk using SQL Server supplied tools. Might be T-SQL, bcp, etc, don't really care I would just like to know a way to do this without resorting to having to write a .NET application.
I've experimented with bcp, using the -c, -n, -N, and -w switches and it will extract the document but it's not formatted correctly. When I open it in Word there is a lot of binary gibberish at the beginning, and while the text is there all formatting is gone.
Thanks!