Sorry, most of my response above is bogus... I confused compression with encryption :-(
Since SA v10 the compress() and decompress() functions have had a second parameter named 'algorithm' which when set to 'gzip' can be used to compress/decompress data that can be exchanged outside of the database server and decompressed/compressed using gunzip/gzip.
-- write compressed contents of variable @data to file data.gz call xp_write_file( 'data.gz', compress( @data, 'gzip' ) ); -- and then decompress it using gunzip call xp_cmdshell( 'gunzip data.gz' );
What about reading the file with xp_read_file() and using the builtin COMPRESS() function to compress data and write it back to file with xp_write_file()?
Note, I can't tell whether the builtin compression with the "zip" algorithm will be compatible with ordinary zipped files. On Linux, using "gzip" should work that way. - Mark's response may indicate that "zip" itself won't work here as expected...