Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Varbinary to text, need help !!!
Message
From
24/04/2002 09:00:25
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Varbinary to text, need help !!!
Miscellaneous
Thread ID:
00648614
Message ID:
00648614
Views:
43
Situation: I have several tables full of integer type configuration information for alarm systems. I have to convert each integer to hex and then I need to concatenate these fields and format them to sent them over the web to the alarm panel. My problem is that I cannot convert varbinary to char, nchar, varchar or nvarchar. I get nothing. I know there is something stupid I'm missing here. Any help would save me from having to calc the hex via math.

Example:

SELECT @x = (SELECT alarm_id FROM alarm_config)
-- alarm_id is an INTEGER value of 1439

CREATE TABLE #temp (test1 VARBINARY(2))

INSERT INTO #temp (@x)

SELECT test1 FROM #temp

I get 0x059F which is the proper conversion to hex, no problem there.
Of course this is only in query analyzer to the screen.

Now I need to get just the "59F" portion of the above to put into a
character string for upload to the alarm. The final upload file will
look something like: C4 59F 3 46555 79D

I started creating a hex conversion table, but then realized that the values I need to convert are well beyond 255, which means math. But it doesn't make sense that I can easily convert this to hex and then do nothing else with it.

Any attempt to select test1 or convert test1 to anything other than back to an integer gives me nothing but space (no errors, just no visible value).

TIA for the advice !!!


Jace
Next
Reply
Map
View

Click here to load this message in the networking platform