locked
Convert JPEG images to binary RRS feed

  • Question

  • Is there a way to take a directory of user jpeg images and convert them to binary files so I can import them into a SQL BLOB table?  I exported some images out of a existing SQL BLOB Table and they have just a .file extension and that is exactly what I need and the files that were extracted from the other server are easy to get into the new server BLOB table.  I however have some images I was provided that have a  .jpg extension that I need converted to binary so I can get these files imported into the new BLOB table as well.  I guess my question is is there a utility that can take an entire directory of images with a .jpg extension and make them binary files?
    Wednesday, August 24, 2016 4:07 PM
    Avatar of CS21475
    0 Points

Answers

  • Hi CS21475,

    See the following sample below.

    CREATE TABLE ImageTable
    (
        Id int,
        Name varchar(50) ,
        Photo varbinary(max) 
    )
    
    INSERT INTO ImageTable (Id, Name, Photo) 
    SELECT 1, 'test', BulkColumn 
    FROM Openrowset( Bulk 'C:\test.jpg', Single_Blob) as image
    
    update DIM_COMPANY set LOGO=BulkColumn 
    FROM Openrowset( Bulk 'C:\logo2\Grupo.png', Single_Blob) as image
    where logo is null 
    Best Regards


    Ricardo Lacerda

    Wednesday, August 24, 2016 6:41 PM
    Avatar of Ricardo Lacerda
    2,842 Points

All replies