Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Storing File as Binary image into SQL server

Author  Topic 

mirfandar
Starting Member

1 Post

Posted - 2005-12-21 : 13:37:42
I am using FileUpload control in ASP.net 2.0 to upload files and store them into SQL server database as an image. I am fine with MS office files, image files and etc. We have Product Center (Proe) engineering software to configure parts and the files generated through this software have PLT extension when I store these files, the file type is Plian/text. I am using Fileupload.PostedFile.Content to get the file type. How can I store PLT, TIF files in SQL server? Please help.

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-12-21 : 14:01:57
Storing images in MS SQL server is a bad design. its called a BLOB, there are many such posts in this forum

its better to store them in a folder and make apointer to them in your database

Oh, welcome to SQLFORUMS

Afrika
Go to Top of Page

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2005-12-21 : 15:13:04
I wouldn't take such an absolute position. To me it depends and needs to be evaluated on a case by case basis. There are pros and cons for both approaches. Read this article: http://www.microsoft.com/resources/documentation/sql/2000/all/reskit/en-us/part3/c1161.mspx
I know it's quite long, but really worth reading. The lower half contains several code samples.

Btw, if you're doing this for SQL Server 2005, you should use the new VARBINARY(MAX) data type. The IMAGE type is deprecated.

--
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Heute schon gebloggt? http://www.insidesql.de/blogs
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-12-21 : 15:31:46
Nice article Frank
however i would swallow everything there.

Its just like cursors, when i first got into MS SQL, we were taught to use cursors for online interactive applications.

Its not always the case, theory vs practical



however i would ask,
have you used BLOB s ? and how many times ?

also have you used it or (do you think any heavily hit site) would employ this method ?

Afrika
Go to Top of Page

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2005-12-21 : 16:01:11
Yes, I have one db where I store files in a table. Usually I do receive +200 research reports from banks, brokers and alike daily. Those mails I save as *.msg file which I transfer to SQL Server. Then there is some small intranet front end where you can choose which mail to read, which is then downloaded to a *.msg file and opened in Outlook. This is a very easy and convenient way for me to distribute information inhouse. Once the data is stored it is neither modified nor deleted anymore. I don't know the exact numbers, but last time I checked there were +50000 rows with ~5 GB of data. Works like a charm.
What I especially value is that there is only one backup mechanism, security mechanism (not everybody is allowed to view those information. Actually there are only ~10 regular users) and I don't have to care for inconsistencies.
There is no heavy traffic on the db. But since it is nothing more than a read-only db, I think this approach will scale pretty well. The link I've mentioned described how MS uses this method for their Terraserver database.
However, when the files are modified regularly or retrieved quite often (like graphic for web pages), I guess I would also choose the filesystem (after some testing, of course.

--
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Heute schon gebloggt? http://www.insidesql.de/blogs
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-12-21 : 16:06:12
first time i have ever heard

Interesting, i must say.

I wont employ it though
Go to Top of Page

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2005-12-21 : 16:09:12
Hey, you should get a life outside of SQL Server.
You must be pretty much in the same time zone than me. Still working?

--
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Heute schon gebloggt? http://www.insidesql.de/blogs
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-12-21 : 16:18:24
quote:
Originally posted by Frank Kalis

Hey, you should get a life outside of SQL Server.
You must be pretty much in the same time zone than me. Still working?

--
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Heute schon gebloggt? http://www.insidesql.de/blogs




Excellent advice, i wont fail to take. what about u?


am signing out. Good night.

its 10.20pm here, whats your time over there


Afrika
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-22 : 01:01:07
Anyway it is easy to store the physical path of the images in the table and retreive them in Front End. Here is other article
http://support.microsoft.com/default.aspx?scid=kb;en-us;317016

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2005-12-22 : 06:48:12
I logged out immediately after posting. It was about the same time then.

...ähem yes, sometimes I might be too strangely addicted to SQL Server.

--
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Heute schon gebloggt? http://www.insidesql.de/blogs
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-22 : 07:45:05
>>...ähem yes, sometimes I might be too strangely addicted to SQL Server.

Thats good for SQL Lovers

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-12-22 : 13:04:48
quote:
Originally posted by Frank Kalis

I logged out immediately after posting. It was about the same time then.

...ähem yes, sometimes I might be too strangely addicted to SQL Server.






its not just SQL server, its the Spirit of ICT. I recall staying up a couple of times all night trying to get some work done. And not noticing the day break. Quite a nasty expierience.

Guess we all need a getaway "holiday"

Ehi

Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-01-08 : 09:19:01
its a bit late, but i just came accross these while reading

http://www.sqlteam.com/item.asp?ItemID=986
http://sqlteam.com/forums/topic.asp?TOPIC_ID=55210
Go to Top of Page
   

- Advertisement -