Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6737239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:13:32+00:00 2026-05-26T11:13:32+00:00

In connection with data replication from SQL Server to DB2 I have the following

  • 0

In connection with data replication from SQL Server to DB2 I have the following question:

On DB2 I have a table containing (for simplicity) two columns: COL1 and COL2.

COL1 is defined as CHAR(20). COL2 is defined as CHAR(10).

COL1 is replicated from SQL by converting a string into hex, e.g. "abcdefghij" to "6162636465666768696A" or "1111111111" to "31313131313131313131" by using the following SQL query:

CONVERT(char(20), cast(@InputString as binary) 2)

where @InputString would be "abedefghij".

In other words COL1 contains the hex value, but as a string (sorry if the wording is incorrect).

I need to convert the hex value back to a string and put this value into COL2.

What should the SQL query be on DB2 to do the convertion? I know how to do this on SQL Server, but not on DB2.

Note: The reason the hex-value is not pre-fixed with "0x" is because style 2 is used in the CONVERT statement.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:13:33+00:00Added an answer on May 26, 2026 at 11:13 am
    select hex('A') from sysibm.sysdummy1; 
    

    returns 41.
    and

    select x'41' from sysibm.sysdummy1;
    

    gives you ‘A’. So you can put that in a for loop and loop through each pair of hex characters to arrive at your original string. Or you can write your own unhex function.

    Taken from dbforums.com /db2/1627076-display-hex-columns.html (edit Nov 2020: original source link is now a spam site)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following connection string: Data Source=localhost\\SQLEXPRESS; , it complains that '' is
We're doing a sort of roll-your-own replication from a SQL Server 2008 R2 database
If I have a table in Excel, populated via an external data connection, how
I have set up transactional replication between two SQL Servers on different ends of
I have a SQL Server 2005 box set up for merge replication to SQL
I'm using c#, and have an open tcpip connection receiving data. Is it possible
I have a flash (ActionScript 3.0) which uses socket connection to send data to
In C++, how can I establish an SQL connection to store data in an
Error: Unable to read data from the transport connection: A blocking operation was interrupted
So, I have an app that uses a SQL Server express db. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.