I have a fun problem,
I have data stored in SQL Server 2008 VARDATA
column as Hex.
I need to see what this translated to string is.
I have tried CONVERT(VarChar(MAX), VARDATA, 2)
and it returns a Varchar value of the hex exactly the same as it is in the VARDATA
.
If I put the value that is in my VARDATA
into an online converter I get the exact value I expect back.
Any help would be appreciated.
Details.
Example of the Hex is
0x003200300031003400300037003200340030003000300035003600380038003300300039
It should work out to.
201407240005688309
EDIT: some additional information. This data starts out in ORACLE it is in a RAW
type column.
We bring the data to SQL Server 2008 via Linked Servers using the below open query.
Select TABNAME, VARKEY, DATALN, VARDATA
from sapsr3.KAPOL
When I use the suggested function on this SQL Server 2008 table below.
Select CONVERT(NVARCHAR(MAX),VARDATA)
from KAPOL
I get these symbols:
㈀ 㜀㜀㠀㠀
If I do the conversion of HEX in Oracle first and then try and bring it over I get an empty column.
Select TABNAME, VARKEY, DATALN, utl_raw.cast_to_nvarchar2(hextoraw(VARDATA)) VARDATA
from sapsr3.KAPOL
Lastly, in the first instance with no conversion in the oracle table the data type for the column VARDATA
is VARBINARY
When I try the conversion in Oracle first is NVARCHAR