2011-02-11 164 views

回答

0

我最后写一个命令行实用程序允许简单的无人值守导出多个图像记录。

Usage: 
RunSQLOLEDB "[connection string]" "[query]" 

e.g. 
To extact all images from table Image into separate files 1.jpg, 2.jpg, etc. 
SQLImageOut "Provider=SQLOLEDB;Data Source=(local);..." "SELECT CONVERT(varchar(50), ImageID)+'.jpg', ImageData from Image" 
or   
SQLImageOut @ConnectionString.txt @Query.sql 

Download Binary

GitHub Source

3

使用命令行BCP实用程序:

c:\temp\>bcp "select Media from tbl_GEO_ElementImage where ElementImageID = 64902" queryout "001.jpg" -T 

当promped,给出以下答案:

Enter the file storage type of field Media [image]: <Enter> 
    Enter prefix-length of field Media [4]: 0 
    Enter length of field Media [0]: <Enter> 
    Enter field terminator [none]: <Enter> 

Do you want to save this format information in a file? [Y/n] n 
+0

我不得不对多个记录做到这一点,所以我最后写一个脚本来产生一系列的这些语句,添加额外的“-n”标志,以避免提示价值。不幸的是,它确实添加了4字节前缀,因为它是默认的,但另一个快速脚本之后删除了前4个字节。感谢帖子,这真的帮了我很大的忙! – 2012-03-13 18:48:30

相关问题