Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Binary field conversion upon insert

Author  Topic 

MrT36
Starting Member

6 Posts

Posted - 2007-07-05 : 16:31:03
Does anyone know of an SQL Server method which allows a select from one table containing a binary field to be placed in a second field in hex format?

If you do a select where you are not wanting the results placed into a new table, you get the hex format. If you do a select where the value is to be placed into a different field (non binary field), then it does not do the conversion.

What I would like to know is what method does SQL Server use to do the conversion when it is not inserting it back into a field. I would like to add this to my insert statment so I get the hex representation in my new field.

Thanks,

MrT36

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-07-05 : 16:36:32
Just use the convert function to put it into the format you want.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

MrT36
Starting Member

6 Posts

Posted - 2007-07-05 : 17:18:28
I have tried converting and casting, but it just keeps being displayed as binary when it is put in the new field which is a varchar field.

MrT36
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-05 : 17:37:09
Try the fn_sqlvarbasetostr or fn_varbintohexstr functions.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

MrT36
Starting Member

6 Posts

Posted - 2007-07-06 : 09:31:02
Thanks! That worked great.

MrT36
Go to Top of Page
   

- Advertisement -