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:
INSERT [tabela_testowa] ( Data ) SELECT * FROM OPENROWSET (BULK N'C:\foty\ch6_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:\test\file.jpg" -T -n -d test
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?
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