Recently, I used SQL Server 7.0 to create a databse which would store
image data, but I don't know how to add it to the database. Appreciated
if anyone would give me a hand. It's urgent. Any reply please go to
Thanks and regards.
Thanks and regards.
Q. How do I store/retrieve text and image data in SQL Server?Quote:> Recently, I used SQL Server 7.0 to create a databse which would store
> image data, but I don't know how to add it to the database. Appreciated
> if anyone would give me a hand. It's urgent. Any reply please go to
A. To store/retrieve this sort of data within TSQL scripts you have to use the
WRITETEXT and READTEXT commands rather than standard INSERT/SELECT statements.
These are documented, with examples, in the books-online but are basically a
real pain to use. There are more manageable commands available from within the
relevant programming languages - e.g. RDO and ADO from VB/C can use GetChunk
and AppendChunk commands - but you still have to manage the image/text
chunks/blocks of data at a time. About the only upside of storing this sort of
data within SQL Server is that it can be kept transactionally consistent with
the other data.
For native ODBC access use the SQLPutData and SQLGetData commands.
If you just want to insert/retrieve an entire image/text then look at the
TEXTCOPY program (textcopy /? for parameters) in the <sql>\BINN directory. It
is a command-line program along the lines of BCP.
There is a very useful (free) dll available from
http://www.chriscrawford.com/DBImage (courtesy of Chris Crawford). It has
three functions:
GetImage Used for getting an image from the database
StoreImage Used to send an image to the database
GetWebImage Used to send a DB image to a browser
If transactional consistency doesn't matter, or can be achieved
programmatically, then it is easier to store the data outside the database as
an ordinary file. Within the database just hold a UNC pointer to where the
file is held. This usually makes it much easier to display/edit the data as
the name can simply be passed to whatever tool is doing the manipulation.
===
v1.03 2000.05.09
Applies to SQL Server versions : All
FAQ Categories : Database Administration, Application Design
and Programming
Related FAQ articles : n/a
Related Microsoft Kb articles : Q194975 - "Sample Functions Demonstrating
GetChunk and AppendChunk"
Other related information : n/a
Authors : Neil Pike
Neil Pike MVP/MCSE. Protech Computing Ltd
(Please reply only to newsgroups)
SQL FAQ (428 entries) see
forumsb.compuserve.com/gvforums/UK/default.asp?SRV=MSDevApps (sqlfaq.zip - L7
- SQL Public)
or www.ntfaq.com/sql.html
or www.sql-server.co.uk
or www.mssqlserver.com/faq
Hi All,
I am new to SQL Server and need some help. This is going to be a simple
question, so I hope I dont get flamed.
I need to add som TIF files to a table field. How do I do this? I actually
want to store the file itself, and not a path name.
Thanks,
Mike Bickham
2. eCommerce solution with FileMaker??
3. How to Add Image in a table column
5. adding images into your tables and view in SQL Server
6. DTS
7. Adding Images to a db table
9. Adding a bitmap to a Jet table: Binding an image control isn't working
10. Add new table and add fields to table - Syntax - Working Code Example
11. need help please:joined tables,add new entries based on one table columns
12. Insert image file in a table with an image type