Problem solve Get help with specific problems with your technologies, process and projects.

Exporting a list of images in a document

I want to export a list of images in a document (*.doc) into SQL Server table using BCP utility. Pls help me to do that. Give me the steps to do it.

BCP is not the tool to use, instead you want to use TEXTCOPY.EXE.

TEXTCOPY.EXE is located in your C:\PROGRAM FILES\Microsoft SQL Server\MSSQL\Binn directory (or that of the instance).

This takes the following parameters:

TEXTCOPY Version 1.0
DB-Library version 8.00.191

Copies a single text or image value into or out of SQL Server. The value is a specified text or image 'column' of a single row (specified by the "where clause") of the specified 'table'.

If the direction is IN (/I) then the data from the specified 'file' is copied into SQL Server, replacing the existing text or image value. If the direction is OUT (/O) then the text or image value is copied from SQL Server into the specified 'file', replacing any existing file.

 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.
To demonstrate it's use consider the following table:
Now we insert some rows into this table. Notice how we also insert a value into our IMAGE column to make this NOT NULL. This is needed by TEXTCOPY.
 INSERT blobby(idcol,BLOB) values(1,0x0) INSERT blobby(idcol,BLOB) values(2,0x0) INSERT blobby(idcol,BLOB) values(3,0x0)
Now from our command prompt we can run the TEXTCOPY.EXE command to insert a specified file into our IMAGE column within a given row.
 TEXTCOPY.EXe /S kenny /D test /T blobby /C BLOB /F c:\mydoc.doc /I /W " WHERE idcol=1 " /usa /Ppassword
This is an undocumented command provided with SQL Server.


For More Information

This was last published in July 2002

Dig Deeper on Microsoft SQL Server Installation

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.