Monday, March 26, 2012

Image to Varchar

Hi All,
I have a small doubt.
How to convert an Imaage of about 110 character length to varchar.
The image is nothing but the text data stored in that format.
While using "convert" function for smaller data,Image to Varchar and
Varchar to Image conversion is successful.
But, here the image is too lengthy.
Kindly, anyone suggest a way.
Thanks,
Dutt.
Dutt
declare @.b binary(4), @.str varchar(255)
select @.b = 3455643
exec master..xp_varbintohexstr @.b, @.str out
print @.str
select cast(cast(cast(0x41 as nvarchar) as varbinary)as varchar)
"Dutt" <Mr.Dutt@.gmail.com> wrote in message
news:1167893950.543251.130570@.31g2000cwt.googlegro ups.com...
> Hi All,
> I have a small doubt.
> How to convert an Imaage of about 110 character length to varchar.
> The image is nothing but the text data stored in that format.
> While using "convert" function for smaller data,Image to Varchar and
> Varchar to Image conversion is successful.
> But, here the image is too lengthy.
> Kindly, anyone suggest a way.
> Thanks,
> Dutt.
>
|||> But, here the image is too lengthy.
What do you mean by 'too lengthy'?
Try:
SELECT CAST(SUBSTRING(MyImageColumn, 1, 110) AS varchar(110))
FROM dbo.MyTable
Hope this helps.
Dan Guzman
SQL Server MVP
"Dutt" <Mr.Dutt@.gmail.com> wrote in message
news:1167893950.543251.130570@.31g2000cwt.googlegro ups.com...
> Hi All,
> I have a small doubt.
> How to convert an Imaage of about 110 character length to varchar.
> The image is nothing but the text data stored in that format.
> While using "convert" function for smaller data,Image to Varchar and
> Varchar to Image conversion is successful.
> But, here the image is too lengthy.
> Kindly, anyone suggest a way.
> Thanks,
> Dutt.
>
|||Hi Dan,
I'm getting some output with that.Even,I have tried it earlier.
But the problem is that the image is being converted into ANSII code,I
suppose.
I'm not getting the actual text.
Thanks
Dutt.
Dan Guzman wrote:[vbcol=seagreen]
> What do you mean by 'too lengthy'?
> Try:
> SELECT CAST(SUBSTRING(MyImageColumn, 1, 110) AS varchar(110))
> FROM dbo.MyTable
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Dutt" <Mr.Dutt@.gmail.com> wrote in message
> news:1167893950.543251.130570@.31g2000cwt.googlegro ups.com...
|||> I'm getting some output with that.Even,I have tried it earlier.
> But the problem is that the image is being converted into ANSII code,I
> suppose.
> I'm not getting the actual text.
How is the text encoded? I would expect that the data would be converted
according to your database default collation. Can you post a raw data
sample (e.g. 0x68656c6c6f) along with your expected results (e.g. 'hello')?
Hope this helps.
Dan Guzman
SQL Server MVP
"Dutt" <Mr.Dutt@.gmail.com> wrote in message
news:1167970260.405637.12700@.11g2000cwr.googlegrou ps.com...
> Hi Dan,
> I'm getting some output with that.Even,I have tried it earlier.
> But the problem is that the image is being converted into ANSII code,I
> suppose.
> I'm not getting the actual text.
> Thanks
> Dutt.
> Dan Guzman wrote:
>

No comments:

Post a Comment