Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Exported Zip is Invalid or corrupted

Author  Topic 

xicom_rakesh
Starting Member

6 Posts

Posted - 2009-08-17 : 03:46:21
Hi

We were trying to export binary data to File system. I'm able to export the file to Varbinary data to File system but the problem is that extracted zip are corrupted. throwing message "Zip file is invalid or corrupted"

Thanks for any kind of help.

Rakesh

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-08-17 : 04:03:13
Fix the bug at line #13.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

xicom_rakesh
Starting Member

6 Posts

Posted - 2009-08-17 : 05:17:54
Some Additional information for the Query

Here is the T-SQL using for Exporing the binary data

set @SQLcommand = 'bcp "SELECT [File] FROM OrderManagementUtility.dbo.OrderBulletinFiles where
orderid='+CAST(@OrderID as varchar(20)) +' and filename='''+@FileName+'''" queryout
"'+@FilePathToExport+@FileName +'" -n -S ' + @@SERVERNAME +' -U '+@SQLUserName+' -P '+@SQLPassword +''

The above exporting the file well but the zip file throwing error when try to extract them.

Thanks

Rakesh
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-08-17 : 05:52:25
What is the result of the

PRINT @SQLcommand

just before the EXEC(@SQLcommand) ?



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

xicom_rakesh
Starting Member

6 Posts

Posted - 2009-08-17 : 06:54:14
Result of PRINT @SQLcommand


bcp "SELECT [File] FROM OrderManagementUtility.dbo.OrderBulletinFiles where orderid=3 and filename='CustomPages.zip'" queryout "E:\OrderManagementUtility\TempExported\CustomPages.zip" -n -S STAGE2 -U **** -P ******

Rakesh



Rakesh
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-08-17 : 07:37:28
The file created is NOT a zip-file. It is a TEXT-file, even if you named it ZIP.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

xicom_rakesh
Starting Member

6 Posts

Posted - 2009-08-17 : 07:44:45
Ok

Do you means that data in table's column is text file?
What should I do to create .Zip Files?

Rakesh
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-08-17 : 07:48:14
Use a third party compression application that takes command line inputs.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

xicom_rakesh
Starting Member

6 Posts

Posted - 2009-08-17 : 07:52:10
Do you have any Idea for any Third Party tools?

I will recommend your suggestion as gold.

Rakesh
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-08-17 : 07:58:21
PkZip.
http://www.pkzip.com/index.php?option=com_content&task=view&id=43&Itemid=336


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-08-17 : 07:59:40
http://www.7-zip.org/


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

xicom_rakesh
Starting Member

6 Posts

Posted - 2009-08-17 : 08:00:03
Thanks
Let me check.

Rakesh
Go to Top of Page
   

- Advertisement -