November 8, 2012 at 3:32 am
I have a database with different tables. one of these tables has an image column more than 50, 000 records.
I have also 40,000 image files in a separate folder C:\ImageFolder with file names the same as primary Key values of the record in the table.
Question: How can I insert these multiple image file from C:\ImageFolder to the corresponding record in the image column.
E.g. Table Name SampleTable (Col_PK, Name,Picture) with sample data (four records)
Col_PK Name Picture
1001 XXX NULL
1002 YYY NULL
1003 ZZZ NULL
1004 ddd NULL
C:\ImageFolder -- has the following three image files
1001.png, 1002.png , 1004.png
Remark: Size of each file is less than or equal to 50KB and will be stored in the database as binary file
How to import image file:
1001.png -> To Record with Col_pk=1001
1002.png -> To Record with Col_pk=1002
1004.png -> To Record with Col_pk=1004
November 8, 2012 at 3:43 am
Have a look at this:
In your case, you may want to adapt it slightly to match your KeyID with image name, but it should get you started.
Also check if you can implement a SSIS solution instead.
Also refer to forum post:
http://www.sqlservercentral.com/Forums/Topic1066764-391-1.aspx
HTH,
B
November 9, 2012 at 3:05 am
Thank you very much for your reply.
Could you explain more about the SSIS solution possibilities?
November 9, 2012 at 4:55 am
You could possibly create a SSIS package to load the data/images into your table using foreach elements.
But this is really only worthwhile if this is going to be a recurring task (and possibly if the people who will be using the process prefer to use a graphical UI to apply changes to the script).
It may also be useful for the point of view of metadata, logging etc as it is (for the most part) built into SSIS - i.e. it's relatively straightforward to add logging into a SSIS package, whilst the pure T-SQL approach would require you to built your logging mechanisms - the same applies to some extent to the error handling.
Additionally, SSIS uses memory quite efficiently so that may be a benefit.
But if your ETL is mostly E and L (or just Load in your case), with very little T, and if you can write your SPs so they don't rely on cursors, then going the SP-only route will probably be fine.
HTH,
B
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply