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
660 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
  • 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now