COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: rr.bi1212 on 24 Feb 2012 09:05:56 AM

Title: How to convert varbinary into varchar in report studio????
Post by: rr.bi1212 on 24 Feb 2012 09:05:56 AM
HI,
can anyone help me replicating this into report studio

SELECT CONVERT(VARCHAR(255),CONVERT(VARBINARY(255),fieldname)) FROM Table Name

Thanks in Advance.
Title: Re: How to convert varbinary into varchar in report studio????
Post by: Grim on 24 Feb 2012 09:45:38 AM
Cast:
http://publib.boulder.ibm.com/infocenter/cbi/v10r1m0/index.jsp?topic=%2Fcom.ibm.swg.im.cognos.ug_cr_rptstd.10.1.0.doc%2Fug_cr_rptstd_id52032sql99_cast.html
Title: Re: How to convert varbinary into varchar in report studio????
Post by: rr.bi1212 on 24 Feb 2012 09:49:47 AM
Grim,

The link you provided is converting a string to varchar......but here I want to convert a field which is varbinary to varchar
Title: Re: How to convert varbinary into varchar in report studio????
Post by: Grim on 24 Feb 2012 09:53:07 AM
Doubt you can convert a binary to char, but the answer still stands.

Syntax
cast ( expression , datatype_specification )

IE. cast ( expression , varchar() )
Title: Re: How to convert varbinary into varchar in report studio????
Post by: rr.bi1212 on 24 Feb 2012 09:57:49 AM
Grim,

Its not working.
Title: Re: How to convert varbinary into varchar in report studio????
Post by: Grim on 24 Feb 2012 10:05:04 AM
What is the business requirement to convert a Binary to Char?

What DB is the backend?
Title: Re: How to convert varbinary into varchar in report studio????
Post by: rr.bi1212 on 24 Feb 2012 10:08:52 AM
SQL server 2008
Title: Re: How to convert varbinary into varchar in report studio????
Post by: rr.bi1212 on 24 Feb 2012 10:38:15 AM
Grim,

cast ( expression , datatype_specification )

this is working. earlier I made a small mistake
Title: Re: How to convert varbinary into varchar in report studio????
Post by: Grim on 24 Feb 2012 01:09:51 PM
Cool.

So just to satisfy my curiosity. Why are you casting a binary to a char?
Title: Re: How to convert varbinary into varchar in report studio????
Post by: rr.bi1212 on 24 Feb 2012 03:34:31 PM
One of the field has binary values....so to get the values of that field we need  to convert it.
Title: Re: How to convert varbinary into varchar in report studio????
Post by: Grim on 27 Feb 2012 07:21:29 AM
Quote from: rr.bi1212 on 24 Feb 2012 03:34:31 PM
One of the field has binary values....so to get the values of that field we need  to convert it.

Yeah...I got that part already...
::)