I am joining these two tables and I would like to send a view of the Test
with its image(s).
Test
- Name (VARCHAR(255))
- TestId (INT)
- StartTime (DATETIME2(7))
- Status (VARCHAR(255))
Images
- ImageId (INT)
- TestId (INT)
- Image (VARBINARY(MAX))
Right now I am doing this:
SELECT Name, t.TestId, StartTime, Status, Image
FROM [Test] t
LEFT JOIN [Images] i ON i.TestId = t.TestId
What I don't like here is that I have multiple rows from the same test but with different images. Is there a convenient way to return only one row of each test with its image(s) ?
My images are not that heavy (max 100KB) and I don't have a lot of images per test (max 10). Here's what I think:
- It might sound crazy but maybe within SQL server there is a way to convert the
Image
s into a list of images as aVARBINARY(MAX)
- I could have 10 columns (image1, image2...) in the view and fill them with the images if they exist (NOT NULL)
I am a bit stuck with these solutions as I don't know a lot about SQL, but I am still trying. Do you see another way to do it? If not, could you help me with useful advice on how to achieve 1. or 2.