We help IT Professionals succeed at work.
Get Started

Converting base64Binary to UTF-8 (String) in SQL Server 2008

5,383 Views
Last Modified: 2016-09-22
Heyas,

I have the following query:


SELECT bd.data_timestamp
       ,bd.*
       ,wbd.*
       ,CAST( CAST(wbd.DATA_TYPE as XML ).value('.','varbinary(max)') AS varchar )

FROM MSGS bd, WMB_data_event wbd
WHERE bd.MSGFLOW_NAME = 'TestDataFlow'
       AND bd.data_timestamp > '2016-01-10 13:30:00'
       AND bd.data_timestamp < '2016-01-10 18:30:00'
       AND bd.TERMINAL_NAME = 'pass'
       AND bd.WMB_MSGKEY = wbd.WMB_MSGKEY
       AND wbd.DATA_TYPE = 10
ORDER BY bd.data_timestamp ASC

I am trying to Convert base64Binary to UTF-8 on the column 'wbd.DATA_TYPE' however when I run the query I get the following problem.

Msg 529, Level 16, State 2, Line 1
Explicit conversion from data type int to xml is not allowed.

How do I resolve this issue any assistance is appreciated.

Thank you.
Comment
Watch Question
Topic Advisor, Page Editor
CERTIFIED EXPERT
Distinguished Expert 2018
Commented:
This problem has been solved!
Unlock 1 Answer and 26 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE