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 2000 Forums
 SQL Server Development (2000)
 Convert VARCHAR to VARBINARY

Author  Topic 

G_Ozama
Starting Member

12 Posts

Posted - 2008-09-03 : 21:22:02
hi... i have an Hex value stored in a VARCHAR column, and i want to "copy" it to a VARBINARY column without losing it records...

here's a sample:
0x110000FF0000 is stored in the column named table_test1 (varchar(180))
when i try to convert using

quote:

BEGIN
DECLARE @TEST1 VARCHAR(180)
DECLARE @TEST2 VARBINARY(180)
SELECT @TEST1 = (SELECT test_table1 FROM test_table)
SELECT @TEST2 = (SELECT CONVERT(varbinary(180),@TEST1))
END
PRINT @TEST2


i get this result:

quote:

0x3078313130303030464630303030


how i can use a similar query to @TEST2 be varchar and exactly as the value is stored in table_test1???

thx in advance

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-04 : 01:25:32
I thought you got an answer here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=108767



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2008-09-04 : 12:47:18
quote:
Originally posted by Peso

I thought you got an answer here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=108767



E 12°55'05.63"
N 56°04'39.26"


Different question.

G-Ozama, I did a search on converting hex strings varbianry that produced many links. Here is one that might help you:

http://blogs.msdn.com/rextang/archive/2008/01/13/7091118.aspx
Go to Top of Page
   

- Advertisement -