Answered by:
Ricardo Lacerda | |
Joined Dec 2007 | |
1 4 18 |
Convert JPEG images to binary
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
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
- Proposed as answer by Olaf HelperMVP Thursday, August 25, 2016 4:27 AM
- Marked as answer by Sam ZhaMicrosoft contingent staff Tuesday, September 6, 2016 1:56 AM
Wednesday, August 24, 2016 6:41 PM
All replies
-
Wednesday, August 24, 2016 4:20 PM
-
Wednesday, August 24, 2016 4:30 PM
-
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
- Proposed as answer by Olaf HelperMVP Thursday, August 25, 2016 4:27 AM
- Marked as answer by Sam ZhaMicrosoft contingent staff Tuesday, September 6, 2016 1:56 AM
Wednesday, August 24, 2016 6:41 PM