Can this be done? I've seen samples that uses winzip but I don't have winzip so I'm wondering if this is doable using the built-in windows compressing utility. This is the VB6 code that does it in Vista, not sure if this is convertible at all to T-SQL. The other option I am looking into is to make a small program/dll that will do it and be called from SQL Server.
Code:Public Sub ZipFile(ByVal strFileToZip As String, ByVal strTargetZip As String, Optional ByVal bolFileType As Boolean = True) CreateEmptyZip strTargetZip Dim folder As Folder3 Dim zipObject As IShellDispatch5 Set zipObject = CreateObject("Shell.Application") Set folder = zipObject.nameSpace(strTargetZip) If bolFileType Then folder.CopyHere strFileToZip Else folder.CopyHere zipObject.nameSpace(strFileToZip).Items End If End Sub Private Sub CreateEmptyZip(ByVal sPath As String) Dim strZIPHeader As String strZIPHeader = Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String$(18, 0) ' header required to convince Windows shell that this is really a zip file CreateObject("Scripting.FileSystemObject").CreateTextFile(sPath).Write strZIPHeader End Sub




Reply With Quote