Friday, February 24, 2012

Bulk import images to binary object in SQL 2000

I have a web application that I am rebuilding. I have many picture files that want to take off the file system and move into SQL as a blob. I will create an index of uids against the file names but need a good way to bulk add the files to the database... any hints on code or tools would be a great help.

Thanks

Bill

You can use a utility 'textcopy' in 'Command Prompt' under the SQL instance directory:

C:\Program Files\Microsoft SQL Server\MSSQL$InstanceName\Binn

FYI, you can use it as following, make sure the command in a single line:

====Copy data from file to table====

textcopy /S labsh96223\iori2000 /I /F c:\xml\iori.bmp /D northwind /T testImage /C img /U sa /P /W "where idx=2"
====Copy data from table to file====

textcopy /S labsh96223\iori2000 /O /F c:\xml\iori.jpg /D northwind /T testImage /C img /U sa /P /W "where idx=2"

You can also use some programming code (written in VC++,C# etc.) to manipulte the binary data of BLOBs between files and database.

No comments:

Post a Comment