| SQL Server allows you to import Word documents in several ways. Let's look at the most common methods. Note that before you import the documents into SQL Server, you need to create an image data type column to store the data. You can then import the documents by using the textcopy.exe command-line utility to read the image files into the database. To obtain basic documentation about this tool, at a command prompt, type textcopy /?. Another approach for importing the Word documents into SQL Server is to write import code by using the Microsoft ActiveX Directory Object (ADO) Stream interface. You can find sample code for this interface in the Microsoft Product Support Services (PSS) article Access and Modify SQL Server BLOB Data by Using the ADO Stream Object. Alternatively, you can move the binary data to SQL Server. For an explanation of this approach, read the PSS article Retrieve and Update a SQL Server Text Field Using ADO. Moving the binary data allows you to store parts of the data in the database and is useful when you need to control the data format. For example, if you want only between 1,000 and 1,010 bytes of the data, importing the binary data can be much faster than using the ADO Stream interface because SQL Server doesn't need to retrieve as much data from disk. People often use this technique to store bit masks that represent application on and off switches. SQL Server 2000 comes with sample code that demonstrates how you can move the binary data. To view this code, just follow the ?\Program Files\Microsoft SQL Server\80\Tools\DevTools\Samples\ado path on the drive where you installed the code samples from your SQL Server 2000 CD-ROM. Expand the executable and look in the Visual Basic directory to find the Samples subdirectory. In the Employee sample, notice how the code uses the FillDataFields() function. To index Word documents, SQL Server 7.0 and SQL Server 2000 provide the full-text search component, which uses a mix of technologies to index large text and image columns. When you perform a full-text search, you need to specify which file type the image column contains and which filter you need to extract meaning from the binary data. Note that indexing Word documents doesn't magically produce a set of relational tables that contain keywords from your documents. However, indexing the files allows you to include these Word documents in your searches. Possible ways of extracting keywords from the data include: Using OLE automation to read user-defined keywords from the document. Save these keywords in relational tables at the same time you load the document. |