There is an undocumented utility in the BINN folder of SQL that will extract binary fields to files (or vice versa). The user has to be a SQL account, not a windows account and has to have read permissions on the table. This can be very useful when you need to extract information from the many binary fields in a SharePoint database. (Note: This utility is only supported in SQL 2000 and not in 2005.)
Here’s the syntax and an example:
TEXTCOPY [/S [sqlserver]] [/U [login]] [/P [password]]
[/D [database]] [/T table] [/C column] [/W"where clause"]
[/F file] [{/I | /O}] [/K chunksize] [/Z] [/?]
/S sqlserver | The SQL Server to connect to. If ‘sqlserver’ is not specified, the local SQL Server is used. |
/U login | The login to connect with. If ‘login’ is not specified, a trusted connection will be used. |
/P password | The password for ‘login’. If ‘password’ is not specified, a NULL password will be used. |
/D database | The database that contains the table with the text or image data. If ‘database’ is not specified, the default database of ‘login’ is used. |
/T table | The table that contains the text or image value. |
/C column | The text or image column of ‘table’. |
/W "where clause" | A complete where clause (including the WHERE keyword) that specifies a single row of ‘table’. |
/F file | The file name. |
/I | Copy text or image value into SQL Server from ‘file’. |
/O | Copy text or image value out of SQL Server into ‘file’. |
/K chunksize | Size of the data transfer buffer in bytes. Minimum value is 1024 bytes, default value is 4096 bytes. |
/Z | Display debug information while running. |
/? | Display this usage information and exit. |
C:Program FilesMicrosoft SQL ServerMSSQLBinn>TEXTCOPY /O /D PBCVirtu1_Site /T Docs /C Content /W"where Id = ‘{0A5498C4-BA8A-4206-8B02-206AAEE9DF8E}’" /F C:tempTempFile.doc /S 10.20.1.63 /U temp_recover /P *******