title: How to insert image file, stored in Azure blob storage, into an Azure SQL table
body: <p>I've set up an Azure blob storage and have uploaded one jpg file into the container.</p>
  
  <p>In SSMS I've created all the external data source and credentials, master key etc.</p>
  
  <p>Now I'm trying to use the BULK insert command to put the image into a table. Essentially this table will store images of HTML previews of emails that have been sent. They will need to have a corresponding ID.</p>
  
  <p>This table will then be fed into powerBI and I'll do base64 encoding in that program to display the image. (found this method: <a href="https://community.powerbi.com/t5/Desktop/How-to-use-Images-Stored-in-a-SQL-Server-Table-with-Power-BI/td-p/383111" rel="nofollow noreferrer">https://community.powerbi.com/t5/Desktop/How-to-use-Images-Stored-in-a-SQL-Server-Table-with-Power-BI/td-p/383111</a>)</p>
  
  <p>However, when trying to run the bulk insert command I get this error:</p>
  
  <p>Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 1 (HTML_Image).</p>
  
  <p>I tried using a varchax(max) column type and it allowed it to go but in a weird format. (when you open an image in notepad - that's what it looks like)</p>
  
  <p>Can anyone recommend a solution?
  Also, am I even using the correct method here as I'm not sure how to insert the ID value with this BULK insert command along with the image?</p>
  
  <pre><code>CREATE TABLE [dbo].[SFMC_HTML_Images](
      [HTML_Image] varbinary(max) NULL,
      SendID varchar(50) null
  ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
  GO
  
  
  BULK INSERT SFMC_HTML_Images
  FROM '4017033.jpg'
  WITH (DATA_SOURCE = 'MyAzureBlobStorage');
  </code></pre>