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
 how to convert image type to varchar(max)

Author  Topic 

harry2ca
Starting Member

2 Posts

Posted - 2011-07-12 : 14:04:23
Hello,
A table contains image type data. Actually it is text file. I don't know how to convert it to text and display. The image data size is about 20kb. Please advise.

Thanks.
Harry

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-07-12 : 14:09:55
SELECT CAST(imageColumn as varchar(max)) FROM myTable

You probably can't display all 20K in Management Studio's query results window, but otherwise that will work.
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2011-07-12 : 14:17:48
I thought you needed to go through varbinary first... but who knows...

Select cast(cast(imageColumn as varbinary(max)) as varchar(max)) From myTable

Corey

I Has Returned!!
Go to Top of Page

harry2ca
Starting Member

2 Posts

Posted - 2011-07-12 : 14:33:26
Thanks for all replys, expecially Corey.
Your solution works for me.
Thanks again. :)
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-07-12 : 14:33:57
Ugh, you're right.

Kids, this is what happens when you don't test your code.
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2011-07-12 : 14:54:54
Kids are what happens when you don't test your code??

You better be damn sure I'll be testing from now on. I don't need anymore

Corey

I Has Returned!!
Go to Top of Page

Baldwin
Starting Member

2 Posts

Posted - 2013-03-25 : 03:10:46
if you wanna convert the image to text file, you have to use a image conveting program, for this, according to my experience, you can search in google or bing and you can get many FREE online image converting solution, this is what im using, hope it can solve your problem.
unspammed
Go to Top of Page

cicorp
Starting Member

1 Post

Posted - 2013-10-09 : 10:25:52
quote:
Originally posted by Seventhnight

I thought you needed to go through varbinary first... but who knows...
Select cast(cast(imageColumn as varbinary(max)) as varchar(max)) From myTable



Thank you Corey. It worked, and saved my data programming contract!
Go to Top of Page

Donna111
Starting Member

4 Posts

Posted - 2013-10-21 : 23:20:57
Hi there
I've never tried to unspammed data to text before.I usually covnert image using an image converter.That would help a lot.You can have a try.Best wishes.
Go to Top of Page
   

- Advertisement -