Loading
Exporting Attachments

Hello all,

I am trying to export all attachments from Flexera for import into another platform.

I am currently using Microsoft SQL Server Management Studio to query the Document table so export where ContractID IN NOT NULL among other tables. I'm running into an issue where the hexadecimal values in the DocumentFile field are getting truncated, or the limit is causing the attachments to become corrupted upon import into the other platform. 

Does anybody know of a viable way to export attachment data from Flex in a way that will preserve the attachment if it is large?

Does the data get chunked out into manageable pieces over multiple records? I have heard of that happening on other platforms, and if it does, does anyone know how that chunking works or where to find the data?

Has anybody done this in a way that worked but maybe with another tool?

Please let me know asap.

If this question belongs in another forum please let me know as well. Not a Flexera expert by any means.

Many thanks


  • ChrisG (Flexera Software)

    The following page describes some ways to get binary blob data out of a SQL Server database and may be helpful: SAVING AND EXTRACTING BLOB DATA – BASIC EXAMPLES

    If you're familiar with PowerShell, writing a PowerShell script to extract and save the data you want (like the last option described on the above page) would be the most flexible approach of the options listed. I can't find a good example of a PowerShell script to do that for the document data in a FlexNet Manager Suite database though, so that remains an exercise for the reader!

    However I did find a script that somebody has written using the "OLE object creation via SSMS" approach described in this article. This approach will only be helpful if you have full admin access to the SQL Server instance and the server it is running on, but if that limitation is not a blocker in your situation then this may be a viable option. Here is the script:

    1. DECLARE CURSOR_Documents CURSOR FOR (SELECT DocumentID FROM dbo.Document_MT WHERE [DocumentTypeID] = 1 /* uploaded document */)DECLARE @DocumentID INTOPEN CURSOR_DocumentsFETCH NEXT FROM CURSOR_Documents INTO @DocumentIDWHILE (@@FETCH_STATUS <> -1)BEGIN DECLARE @ImageData varbinary(max) SELECT @ImageData = (SELECT convert(varbinary(max), [DocumentFile], 1) FROM dbo.Document_MT WHERE [DocumentID] = @DocumentID) DECLARE @Path nvarchar(1024) SELECT @Path = 'C:\Temp' DECLARE @Filename NVARCHAR(1024) SELECT @Filename = (SELECT [DocumentName] FROM dbo.Document_MT WHERE [DocumentID] = @DocumentID) DECLARE @FullPathToOutputFile NVARCHAR(2048) SELECT @FullPathToOutputFile = @Path + '\[' + CONVERT(varchar(5), @DocumentID) + ']' + @Filename PRINT 'Document: ' + @FullPathToOutputFile DECLARE @ObjectToken INT EXEC sp_OACreate 'ADODB.Stream', @ObjectToken OUTPUT EXEC sp_OASetProperty @ObjectToken, 'Type', 1 EXEC sp_OAMethod @ObjectToken, 'Open' EXEC sp_OAMethod @ObjectToken, 'Write', NULL, @ImageData EXEC sp_OAMethod @ObjectToken, 'SaveToFile', NULL, @FullPathToOutputFile, 2 EXEC sp_OAMethod @ObjectToken, 'Close' EXEC sp_OADestroy @ObjectToken FETCH NEXT FROM CURSOR_Documents INTO @DocumentIDENDCLOSE CURSOR_DocumentsDEALLOCATE CURSOR_Documents

     

    Expand Post

Related  Product Forums


                     â†’ Flexera One



                      â†’ Snow Atlas



                      â†’ FlexNet Manager



                      â†’ Snow License Manager



                       â†’ App Broker


       Need help finding an answer?


        Ask a Question →


Loading
Exporting Attachments