How to insert 100 images in single query?

  • In my table there is column name "imgdata" with extact 100 rows. I have images for that column which is saved in a particular folder containing extact 100 images and named as 1.jpg, 2.jpg....till 100.jpg.

    '1.jpg' means image named "1" belongs to 1st row of imgdata column.

    Now, i want to insert these images from 1 to 100 in the table with extact 100 rows in single query. So please can any one tell me the query for the same. I am new to SQL.

  • Assuming you are trying to store images in the table as blobs or raw data, you may have to write a small loop iterating from 1 to 100 and then insert the images into tables one by one.

    small steps:

    1. get the name of files and store it in a table variable

    2. get the filenames in sorted manner as 1.jpg will be at top followed by 2.jpg and so on...

    3. try to insert the retreived file name into the row, i would recommend storing file information in another column.

    you can insert all the rows in single transaction if you like.

    Alternatively, you can store the files in random order in the table but fetch the data in sorted manner.

    btw, why you want the image 1 to be inserted in first row. is there any business rule behind it.

  • Data in the row one is related to the image so it is neccessary for me to indert 1.jpg image in 1st row only. Further, can you provide me the solution with some code as i told before only i m new to SQL.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply