Solved

how do i convert binary values obtained from sql server 2005 to varchar and display in ms access 2007 queries

Posted on 2008-10-16
8
668 Views
Last Modified: 2010-04-21
i am trying to create a query in ms access where in i am obtaining a binary value from sql server 2005. i am not able to display the same in ms access 2007. it is showing some junk values. i actually want to convert this to varchar so that i can link that field to another varchar field in the tables to display the values. please help me out. i am trying to create a custom function in ms access which convert binary to varchar so that i can use that varchar in queries
0
Comment
Question by:karthik_kota
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 9

Expert Comment

by:Sander Stad
ID: 22730668
There is a function in MS SQL Server 2005 that converts it for you. This is the function: fn_varbintohexstr
Look at this for more information: http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_20289438.html
0
 
LVL 9

Expert Comment

by:Sander Stad
ID: 22730677
In conjunction with the method you could use a linked server to the access database to get the data from the MS SQL server to the table in MS Access
0
 

Author Comment

by:karthik_kota
ID: 22730842
yes i do know about the function fn_varbintohexstr. also there is dbo.hex function. but i dont want to make any changes in sql 2005. i am actually looking for a custom function(vb script) in ms access which converts binary to varchar and displays the binary value properly(instead of using junk values) when used in ms access queries and should be able to link that field to another varchar field to obtain values
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:karthik_kota
ID: 22730930
the binary data is like this "0x174795BED6B1B141B55628E500FC50FC". this is of binary datatype. i want to convert this to varchar format by creating a custom function in ms access. please help me out. i dont want to make any changes in sql
0
 

Author Comment

by:karthik_kota
ID: 22730937
is there any function in ms access which does that.
0
 

Author Comment

by:karthik_kota
ID: 22737827
ok i will make it simple. i have dbo.contact. persid(varchar) and dbo.chg. uuid(binary). both are from different tables. i have imported these tables from sql server 2005. now i want to link these two fields in ms access 2007 query ( when contact.persid = chg.uuid) and get the results displayed. but since both are of different datatypes. i am not able to get the results from querry. please help me out in having a custom function to convert binary to varchar. ultimately i want to see the results from the querry overcoming the problem in datatype
0
 
LVL 2

Accepted Solution

by:
jchevali earned 500 total points
ID: 23166280
There is a way:

Navigate to this address and borrow the TSToHex() function:
http://kbalertz.com/170380/TimeStamp-Value-Server.aspx

Change the function parameter to be a String instead of a rdocolumn.
Change the For command in TSToHex() to read like this:
For b = 1 To LenB(sBinRep)

In Access, add the function to a public code module.
Add a linked table to the SQL table containing your binary(16) field.
Add a new Access query, switch to SQL view, and enter the following:
SELECT TSToHex(LeftB(uuid,16)) FROM dbo_chg;
Switch to data view.

The contents of the binary field should now be displayed as a hex string.
0
 

Author Closing Comment

by:karthik_kota
ID: 31506702
perfect sollution
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question