| Author |
Topic |
|
LearnSQL
Starting Member
12 Posts |
Posted - 2002-01-07 : 12:25:21
|
| Hi!I would like to insert data into an image column of a table.I have a table set up as: CREATE TABLE dbo.Attach ( GCode varchar(12) NOT NULL, doc_file image NULL)Specifically, word document will be saved in a binary data column so that GCode column will be a unique identifier to identify doc_file column.Was trying to use .bat file to load the data to a file but without any success.Would you have any idea how MS word document can be saved in an image column?Thank you for your help in advance! |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2002-01-07 : 18:51:48
|
| I would encourage you to read the FAQ we have on that topic, and think long and hard about whether you REALLY want to do that. If you do, the FAQ will get you started. Also do a lot of reading in BOL about image datatypes because they have several special "features" that you have to deal with.--------------------------------------------------------------1000 Posts, Here I come! I wonder what my new title will be... |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
|
|
LearnSQL
Starting Member
12 Posts |
Posted - 2002-01-09 : 07:47:56
|
| Thank you very much for your replies!I successfully loaded document file content using TEXTCOPY.It seems that general consensus is not to use image data type to store file contents. We will evaluate the system and think hard before further going ahead with storing image type in a table column in the future.Thanks again for your help!:) |
 |
|
|
jackstow
Posting Yak Master
160 Posts |
Posted - 2002-01-09 : 09:24:42
|
| I think it's a bit sweeping to say never store images in the database - it really depends on the situation - and presenting the image to the browser is not too much of a problem - http://aspfree.com/aspnet/downloadimage.aspx - it makes your db bigger sure, but it can be really useful further down the line to have your records and images stored in the same place. For example, I recently worked on a site that was based on another site. Both sites used the same SQL Server database, with data filtered out for one site or the other. Content, including images, is uploaded to both sites through one content management system, so the data for both is updated, but any images uploaded are only on one site. Therefore the images have to referenced by absolute paths (http://www.bigsite.com/images/image.gif) for the second site. It would have been really useful to have the image for each record in the db in this situation. Also it would have sorted out any missing or invalid image files.Jack |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2002-01-09 : 09:35:06
|
| Hmmm, yeah it may be easier to move a whole system. But it's a pain getting stuff in and out. Also, it's a hell of a lot slower out of the DB.Damian |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-01-09 : 10:24:59
|
| Another 2¢, if you're interested:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=10477Afterwards I thought of several other shortcomings (well, I felt they were!) with storing image data, but I can't find them now!I wanted to clarify a point too: I'm not against storing image data in a DB, I just feel that it's not a good idea in a web environment. If you've got a solution that works well in your environment, by all means use it! IMHO I feel that keeping image files on the drive is not a problem anyway, so I don't feel the need to have a database solution.One thing I'm curious about though: if you want to have multiple images on the same page, and also HTML text or other content? I haven't heard of or seen a good solution that allows mixing HTTP content types on the same page (I'm not sure if this code lets you do that...I can't tell based on just reading it:)http://aspfree.com/aspnet/downloadimage.aspxThis does work if you link the individual image pages onto another, master page, but that doesn't seem too efficient to me...and you'd have to modify that code considerably. Considering that a linked image or other file can just be dropped into the HTML, you could easily have any mix of content on the same page, and with only one call to the database server. |
 |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2002-01-09 : 13:54:43
|
| I, too, don't mean to discard without thought the idea of storing images or other BLOBs in a database. I DO mean to encourage people to SLOW DOWN AND THINK before they start storing information that way. It seems to me that too often somebody gets the idea in their head, discovers it is possible and just runs with it rather than stopping and asking whether it's a good idea.One of the issues we looked at when deciding about images in the database was the impact on network traffic. Pulling the images out of a database dramatically increased network traffic for us. So, along with everything else, that was one more reason we chose not to do it. |
 |
|
|
|