Search code examples
sqlsql-server-2008t-sqlbcp

BCP doc,xls and jpg export are corrupted


Im trying to export files using BCP. Following is a example code and output from this is a corrupt file. Appreciate your help

BCP "SELECT FILE FROM [R3152].[dbo].[Document] with(nolock) WHERE DocumentID =1001" queryout C:\ep\1001_Lighthouse.jpg -n -T


Solution

  • Powershell BinaryWriter did the magic..

    http://social.technet.microsoft.com/wiki/contents/articles/890.export-sql-server-blob-data-with-powershell.aspx