473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How to convert to regular text, data stored in Image data type field ????

SD
Hi,

This is driving me nuts, I have a table that stores notes regarding an
operation in an IMAGE data type field in MS SQL Server 2000.

I can read and write no problem using Access using the StrConv function and
I can Update the field correctly in T-SQL using:

DECLARE @ptrval varbinary(16)
SELECT @ptrval = TEXTPTR(BITS_data)
FROM mytable_BINARY WHERE ID = 'RB215'

WRITETEXT OPERATION_BINARY.BITS @ptrval 'My notes for this operation'

However, I just can not seem to be able to convert back to text the
information once it is stored using T-SQL.

My selects keep returning bin data.

How to do this! Thanks for your help.

SD
Jul 20 '05 #1
1 26186
SD (sd@nospam.net) writes:
This is driving me nuts, I have a table that stores notes regarding an
operation in an IMAGE data type field in MS SQL Server 2000.

I can read and write no problem using Access using the StrConv function
and I can Update the field correctly in T-SQL using:

DECLARE @ptrval varbinary(16)
SELECT @ptrval = TEXTPTR(BITS_data)
FROM mytable_BINARY WHERE ID = 'RB215'

WRITETEXT OPERATION_BINARY.BITS @ptrval 'My notes for this operation'

However, I just can not seem to be able to convert back to text the
information once it is stored using T-SQL.

My selects keep returning bin data.


You can do:

create table img(a image)
go
insert img(a) values (0x41434549)
go
select convert(varchar(8000), convert(binary(8000), a)) from img

But obviously you would not have chosen image, if your data is
less than 8000 bytes, so can only get piece by piece this way.

It may be better to do it client-side, for instance that StrConv
function in Access.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: zhaounknown | last post by:
I have a field set to Image data type, and store a long string(possible other objects)into it with size 5663, and returned with 5663+28 bytes. These strings wil be deserialized after retrieving....
4
by: Andy | last post by:
Hello All: I have a field in the database that is an Image. I have no idea how the data is stored in here (Image, compressed, encrypted, plain text, etc). I am trying to write the contents to...
2
by: MattB | last post by:
I have a slightly different twist on the old question "How do I display images stored in my database?". My application does not talk directly to the database. It uses a COM+ dll to deliver...
2
by: UJ | last post by:
I have need to convert a text string (with formatting) to an image. This is so that I can resize the image to different sizes and the formatting stays exactly the same regardless of the size. I...
20
by: Abhishek | last post by:
can anybody tell how to fetch image from database(access) to the visual basic picture box control. the code i have been using is as below but it gives me invalid paramter error.... Dim...
3
by: PaulJS | last post by:
Hi, I'm just getting started w/ VB.NET. I've been doing database development in MS Access, both as Access databases or as a front end for SQL Server. I need to create a VB.NET app to do some...
2
by: Ed | last post by:
Hope someone can help me out... I have been tasked to read some image data from an sql database and save the files to flat files. OK, sounds easy as I'v used BLOBs before. But this is an old...
3
by: =?Utf-8?B?SlA=?= | last post by:
Explanation: We have several SP that need to retrieve a single "Default Photo" from one of several Photo tables. The column in question in these tables is defined as an IMAGE data type. I...
1
by: Rishabh Indianic | last post by:
hi, i am trying to update data stored in data base with following code i am able to show data from database but i can not able to update it. int Theme_ID = Convert.ToInt32(textBox1.Text);...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.