SQL Server BCP 导出损坏的文件? [英] SQL Server BCP export corrupted file?

查看:58
本文介绍了SQL Server BCP 导出损坏的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 SQL Server 2012 中的 BCP 功能有一个小问题.事情是:我使用以下命令加载 .jpg 图像(大小为 167KB):

i have a small problem with BCP functionality in SQL Server 2012. The things is: im loading .jpg image (167KB in size) using below command:

插入 [tabela_testowa] ( 数据 )SELECT * FROM OPENROWSET (BULK N'C:fotych6_MagicShop.jpg', SINGLE_BLOB) a;

INSERT [tabela_testowa] ( Data ) SELECT * FROM OPENROWSET (BULK N'C:fotych6_MagicShop.jpg', SINGLE_BLOB) a;

然后我尝试使用以下方法将其导出回磁盘:

and then im trying to export it back to disk using:

BCP "SELECT data FROM tabela_testowa WHERE ID = 1" queryout "C: estfile.jpg" -T -n -d test

BCP "SELECT data FROM tabela_testowa WHERE ID = 1" queryout "C: estfile.jpg" -T -n -d test

文件保存在磁盘上没问题,大小也是 167 KB 但是..它不能像原始副本一样打开.我不知道 BCP 导出中的某些参数有什么问题?或者它可能在导入阶段被损坏?有人遇到过类似的问题吗?

File gets saved on disk no problem, size is also 167 KB but.. it cant be opened like the original copy. I dont know whatever some parameter is wrong in BCP export? Or maybe it gets corrupted at import stage? Anyone had similiar problems?

推荐答案

好的所以我解决了这个问题.必须使用 -f 和文件路径添加格式文件.它可以通过运行 bcp 不带任何格式创建并命令它保存格式文件到磁盘.那么我们就可以使用这个格式文件,这样就不再需要回答那些问题了,而且文件本身没有额外的数据,可以毫无问题地打开

OK so i solved the issue. Format file has to be added using -f and path to the file. It can be create by running bcp without any format and order it to save format file to disk. Then we can use this format file so its no longer needed to answer those questions, and file itself has no additional data and can be opened without problems

这篇关于SQL Server BCP 导出损坏的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆