Search code examples
sql-serverbcp

Difference between BCP versions. On example of exporting data


I am facing the problem with BCP (bulk-copy program) on MSSQL-Server 13.0. Here it goes:

I am trying to export data with that program but file is always corrupted. I am exporting a .zip file. But it works perfect on MSSQL-Server 11.0 - the same command can export any zip file that I need to export.

Command that I am using to export:

bcp "select query" queryout "C:\export\myzip.zip" -T -S SERVER_NAME

Tried to use -V flag, but it didnt work.


Edit 1: After command is used BCP shows me questions about prefix, format and etc - I am using: I 0 0 (space) n


Edit 2: The starting bytes of the exported file are: 37 7a bc af 27 1c


Solution

  • Looking here for the file signature, it appears to be a 7-zip file format. So AFAICT the file was exported correctly. The extension is .7z though, not .zip.

    You can see that here if you search for the starting bytes 37 7a bc af 27 1c.