# Retrieving Image from DB and inserting into perspective table

**URL:** <https://forum.inductiveautomation.com/t/retrieving-image-from-db-and-inserting-into-perspective-table/55409>\
**Category:** Ignition\
**Tags:** ignition80, perspective, scripting\
**Created:** [January 26, 2022, 4:19pm UTC](https://forum.inductiveautomation.com/t/retrieving-image-from-db-and-inserting-into-perspective-table/55409 "2022-01-26T16:19:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel\_Villasenor\_Es](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/miguel_villasenor_es/32/60416_2.png) [@Miguel\_Villasenor\_Es](https://forum.inductiveautomation.com/u/Miguel_Villasenor_Es)\
**Post date:** [January 26, 2022, 4:19pm UTC](https://forum.inductiveautomation.com/t/retrieving-image-from-db-and-inserting-into-perspective-table/55409/1 "2022-01-26T16:19:44Z")

</div>

Hello, I am currently struggling with something.

1. I have a database in MSSQL that has some images. They are currently stored as DataType:Image.
2. I am binding a perspective table to a named query, this named query returns an image/images.  
However the table won’t display the image and I’ve googled around for a bit now. I’ve come across a forum: [View Images from Database - #5 by jpark](https://forum.inductiveautomation.com/t/view-images-from-database/22626/5) where they help you with a transform script.
3. I’ve tried the transform script which is:b64Image = “data:imagef;base64,%s”%value return b64Image. It’ll convert the returned sql value into base64 string so that the perspective table can display it. But I can NOT get it to work. I’ve tried changing the Data Type from image to: nvarchar(max) and varbinary(max). I’ve converted the image straight into base64 with some programming magic, and the table still won’t be able to display the image. What Can I do to display a picture in my Perspective table from a database.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [January 27, 2022, 10:46am UTC](https://forum.inductiveautomation.com/t/retrieving-image-from-db-and-inserting-into-perspective-table/55409/2 "2022-01-27T10:46:57Z")

</div>

> [@View Images from Database](https://forum.inductiveautomation.com/t/view-images-from-database/22626/5):
>
> convert it to base64 in the query with TO\_BASE64(ImageData).

are you also doing this? (tho it might be a different funciton in mssql)

How many images are you planning to store here and show in a table. How often will the user change said image?  
As it might be easier to store them in a file instead of a db. Which will also up the performace of the image loading

---

<div class="post-metadata">

**Author:** ![Miguel\_Villasenor\_Es](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/miguel_villasenor_es/32/60416_2.png) [@Miguel\_Villasenor\_Es](https://forum.inductiveautomation.com/u/Miguel_Villasenor_Es)\
**Post date:** [February 16, 2022, 10:04pm UTC](https://forum.inductiveautomation.com/t/retrieving-image-from-db-and-inserting-into-perspective-table/55409/3 "2022-02-16T22:04:17Z")

</div>

Thanks for the help. A little while ago, I managed to get this to work.
