Getting the files stored in a database table?

  • Hi All,

    I am struggling to find a solution / guidelines / 3rd party or internal database tools that allows me to extract files stored in a database table. These files have multiple formats, PDF, Word, Excel, Images etc.

    Please advise me, I have limited or no knowledge on visual studio.

    Thanks

    Yasar

  • The SSIS Export Column Transformation can do that for you.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Hello, you don't need any third party tool.

    You can extract binary files from SQLServer BLOB fields using VBScript.

    I am using a script (a simple text file with .vbs extension) like this:

    option explicit

    const adOpenKeyset = 1

    const adLockOptimistic = 3

    const adTypeBinary = 1

    const adSaveCreateOverWrite = 2

    dim cn, rs, mstream

    set cn = CreateObject("ADODB.Connection")

    cn.Open "Provider=SqlOLEDB;Server=myServerName;Database=myDbName;UID=myUserId;PWD=myPwd"

    set rs = CreateObject("ADODB.Recordset")

    rs.Open "select BlobFieldName from TableName where Code='xyz'", cn, adOpenKeyset, adLockOptimistic

    set mstream = CreateObject("ADODB.Stream")

    mstream.Type = adTypeBinary

    mstream.Open

    mstream.Write rs.Fields("BlobFieldName").Value

    mstream.SaveToFile "C:\FileSavedFromBlob.pdf", adSaveCreateOverWrite

    rs.Close

    cn.Close

    set rs = nothing

    set cn = nothing

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply