Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Stored procedure to convert blob to image file

Posted on 2007-07-22
6
Medium Priority
?
1,409 Views
Last Modified: 2008-09-19
Windows 2003 Server running IIS and SQL Express 2005

I have clients who send records containing some images to my SQL server. (Each record can contain upto 10 image fields)  Although using  blobs to contain images on their client software is a good idea, I would prefer to use the local file system for the purpose of displaying the images from IIS

I am hoping to create a trigger on the SQL Server so as a record is updated or added, the blob is saved to the local file system as an image file. It then can be access by IIS and displayed to a users browser.

I am not an expert on SQL Server, but I figured a stored procedure could be called by the trigger ...

Is this possible from withing a stored procedure?


0
Comment
Question by:bewildered
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:bamboo7431
ID: 19542476
"Although using  blobs to contain images on their client software is a good idea"
Why?
Create a root directory called, say, D:\ClientImages
Under it have a folder for each client. When the client 5 uploads an image mypic.jpg, place it into D:\ClientImages\5\mypic.jpg
If you don't let them create folders, but only to place the images in one directory, your table will look like:
(clientID, fileName) with the values(5,'mypic.jpg')
That was the file is always on the file system, you lower the storage costs on the DB tremendously and everyone is happy
0
 

Author Comment

by:bewildered
ID: 19542536
Hi,

A Data entry person adds records to an access db that include images. The access DB is then copied to one or more laptops for sales staff to go on the road with.

This is a simple and clean method to make the data available to staff who do not have an internet connection available while travelling.

The Data entry person also uploads the records from the central access DB to the SQL server. At this point I would like to create the individual image files for use on the website.

Cheers Tony
0
 
LVL 4

Accepted Solution

by:
bamboo7431 earned 2000 total points
ID: 19542637
How many records they are going to have?
Access is known for bloating as it's being used. Storing images in Access is sure going to push it towards the 2 Gb file size limit ( http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B302524 ) and, believe me, you will start getting problems way before it reaches 2 Gb.

I guess if you're only use Access as a way to view the files and never to modify it, it can fly. But there's nothing that forces you to store images in the central database as opposed to file system (which is what you want anyway).

I'm not trying to be overly critical, just the database is a bad place for storing images - it doesn't give pretty much any benefits, and causes you troubles when you try to display them. So rather than work around a bad design by writing triggers and exporting files to the disk, why not change the bad design and store the files on disk to begin with?
0
 

Author Comment

by:bewildered
ID: 19542817
Thanks for the input,

I think I will abandon the question ...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question