2

How can I import a PNG to an SQL Server database installed in a machine where I'm not granted access (except to the DB instance)?

I cannot do the following because I cannot access the disk:

INSERT INTO [dbo].[WorkItemState]  (ImageBits)
SELECT  BulkColumn 
FROM OPENROWSET  (BULK 'C:\checkbox.png', SINGLE_BLOB) as MyImage 

Is there a way to convert the PNG to a recognizable format that I can simply copy/paste on my table column?

Luis Gouveia
  • 211
  • 1
  • 3
  • 8

1 Answers1

3

You can encode your image with base64 like:

cat YOUR_IMAGE.png | base64 or directly base64 YOUR_IMAGE.png and add the output to your database.

deagh
  • 1,969
  • 5
  • 18
  • 16