SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to convert image type to varchar(max)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

harry2ca
Starting Member

2 Posts

Posted - 07/12/2011 :  14:04:23  Show Profile  Reply with Quote
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

USA
15676 Posts

Posted - 07/12/2011 :  14:09:55  Show Profile  Visit robvolk's Homepage  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
2878 Posts

Posted - 07/12/2011 :  14:17:48  Show Profile  Visit Seventhnight's Homepage  Reply with Quote
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 - 07/12/2011 :  14:33:26  Show Profile  Reply with Quote
Thanks for all replys, expecially Corey.
Your solution works for me.
Thanks again. :)
Go to Top of Page

robvolk
Most Valuable Yak

USA
15676 Posts

Posted - 07/12/2011 :  14:33:57  Show Profile  Visit robvolk's Homepage  Reply with Quote
Ugh, you're right.

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

Seventhnight
Flowing Fount of Yak Knowledge

USA
2878 Posts

Posted - 07/12/2011 :  14:54:54  Show Profile  Visit Seventhnight's Homepage  Reply with Quote
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

USA
2 Posts

Posted - 03/25/2013 :  03:10:46  Show Profile  Reply with Quote
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

USA
1 Posts

Posted - 10/09/2013 :  10:25:52  Show Profile  Reply with Quote
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

USA
4 Posts

Posted - 10/21/2013 :  23:20:57  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000