我只是希望能够将jpg数据从单个记录导出到文件,而无需每次都编写程序。
查询:
select Media from tbl_GEO_ElementImage where ElementImageID = 64902
答案 0 :(得分:4)
使用命令行BCP实用程序:
c:\temp\>bcp "select Media from tbl_GEO_ElementImage where ElementImageID = 64902" queryout "001.jpg" -T
提示时,请提供以下答案:
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
答案 1 :(得分:1)
我最终编写了一个命令行实用程序,允许简单无人值守地导出多个图像记录。
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